Skip to content

gh-131878: Fix input of unicode characters with two or more code points in the REPL on Windows in vt mode #133030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

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.

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