X Tutup
Skip to content

Commit b239067

Browse files
committed
Fix non-ascii input in Python 3.
1 parent fdb8343 commit b239067

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bpython/cli.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,13 @@ def get_key(self):
543543
while True:
544544
try:
545545
key += self.scr.getkey()
546-
if not py3:
546+
if py3:
547+
# Seems like we get a in the locale's encoding
548+
# encoded string in Python 3 as well, but of
549+
# type str instead of bytes, hence convert it to
550+
# bytes first and decode then
551+
key = key.encode('latin-1').decode(getpreferredencoding())
552+
else:
547553
key = key.decode(getpreferredencoding())
548554
self.scr.nodelay(False)
549555
except UnicodeDecodeError:

0 commit comments

Comments
 (0)
X Tutup