mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-131878: Fix input of unicode characters with two or more code points in new pyrepl on Windows (gh-131901)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com> Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
This commit is contained in:
parent
d6078ed6d0
commit
0c5151bc81
4 changed files with 68 additions and 27 deletions
|
@ -69,18 +69,14 @@ class BaseEventQueue:
|
|||
trace('added event {event}', event=event)
|
||||
self.events.append(event)
|
||||
|
||||
def push(self, char: int | bytes | str) -> None:
|
||||
def push(self, char: int | bytes) -> None:
|
||||
"""
|
||||
Processes a character by updating the buffer and handling special key mappings.
|
||||
"""
|
||||
assert isinstance(char, (int, bytes))
|
||||
ord_char = char if isinstance(char, int) else ord(char)
|
||||
if ord_char > 255:
|
||||
assert isinstance(char, str)
|
||||
char = bytes(char.encode(self.encoding, "replace"))
|
||||
self.buf.extend(char)
|
||||
else:
|
||||
char = bytes(bytearray((ord_char,)))
|
||||
self.buf.append(ord_char)
|
||||
char = ord_char.to_bytes()
|
||||
self.buf.append(ord_char)
|
||||
|
||||
if char in self.keymap:
|
||||
if self.keymap is self.compiled_keymap:
|
||||
|
|
|
@ -485,7 +485,8 @@ class WindowsConsole(Console):
|
|||
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, "replace"):
|
||||
self.event_queue.push(char)
|
||||
continue
|
||||
|
||||
if key_event.dwControlKeyState & ALT_ACTIVE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue