Skip to content

Conversation

chris-eibl
Copy link
Member

@chris-eibl chris-eibl commented Apr 26, 2025

ab8efa7 is the fix on top of the reverted #130805.

49078f3 shows how I'd like to only accept bytes of length=1 in BaseEventQueue.push().

Only the tests used the int code path somewhat non-transparent by using strings which got converted to due to else ord(char) to bytes of length=1 again:

        ord_char = char if isinstance(char, int) else ord(char)
        char = bytes(bytearray((ord_char,)))

Maybe too much churn, thus just a draft.

@@ -468,7 +468,9 @@ def get_event(self, block: bool = True) -> Event | None:
return None
elif self.__vt_support:
# If virtual terminal is enabled, scanning VT sequences
self.event_queue.push(rec.Event.KeyEvent.uChar.UnicodeChar)
for char in raw_key.encode(self.event_queue.encoding,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to use PEP-467 iterbytes() here :)

@sergey-miryanov
Copy link
Contributor

I like this proposal.

@chris-eibl
Copy link
Member Author

Closing since #131901 is merged and backported.

@chris-eibl chris-eibl closed this May 6, 2025
@chris-eibl chris-eibl deleted the fix_vt_windows branch May 6, 2025 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants