summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl/base_eventqueue.py
diff options
context:
space:
mode:
authorSergey Miryanov <sergey.miryanov@gmail.com>2025-05-05 16:25:00 (GMT)
committerGitHub <noreply@github.com>2025-05-05 16:25:00 (GMT)
commit0c5151bc81ec8e8588bef4389df12a9ab50e9fa0 (patch)
treeae41e635dbdbd547938b47a0938ae8050708480a /Lib/_pyrepl/base_eventqueue.py
parentd6078ed6d0cb8745460769bbb5dd2392c91c2f55 (diff)
downloadcpython-0c5151bc81ec8e8588bef4389df12a9ab50e9fa0.zip
cpython-0c5151bc81ec8e8588bef4389df12a9ab50e9fa0.tar.gz
cpython-0c5151bc81ec8e8588bef4389df12a9ab50e9fa0.tar.bz2
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>
Diffstat (limited to 'Lib/_pyrepl/base_eventqueue.py')
-rw-r--r--Lib/_pyrepl/base_eventqueue.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/Lib/_pyrepl/base_eventqueue.py b/Lib/_pyrepl/base_eventqueue.py
index e018c4f..842599b 100644
--- a/Lib/_pyrepl/base_eventqueue.py
+++ b/Lib/_pyrepl/base_eventqueue.py
@@ -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: