comparison mercurial/ui.py @ 43118:57efd5bd2ca2

py3: decode prompt string before calling rawinput Calling input() (aka pycompat.rawinput() on python3) with a byte string displays a byte string in the console. E.g. in interactive commit, we get: b"examine changes to '<file>'?\n(enter ? for help) [Ynesfdaq?]". Similarly, "hg email" prompts are messed up. We thus decode the prompt string before running rawinput().
author Denis Laxalde <denis.laxalde@logilab.fr>
date Wed, 09 Oct 2019 15:28:16 +0200
parents d783f945a701
children 82879e06c926
comparison
equal deleted inserted replaced
43117:8ff1ecfadcd1 43118:57efd5bd2ca2
1553 1553
1554 # prompt ' ' must exist; otherwise readline may delete entire line 1554 # prompt ' ' must exist; otherwise readline may delete entire line
1555 # - http://bugs.python.org/issue12833 1555 # - http://bugs.python.org/issue12833
1556 with self.timeblockedsection(b'stdio'): 1556 with self.timeblockedsection(b'stdio'):
1557 if usereadline: 1557 if usereadline:
1558 prompt = encoding.strfromlocal(prompt)
1558 line = encoding.strtolocal(pycompat.rawinput(prompt)) 1559 line = encoding.strtolocal(pycompat.rawinput(prompt))
1559 # When stdin is in binary mode on Windows, it can cause 1560 # When stdin is in binary mode on Windows, it can cause
1560 # raw_input() to emit an extra trailing carriage return 1561 # raw_input() to emit an extra trailing carriage return
1561 if pycompat.oslinesep == b'\r\n' and line.endswith(b'\r'): 1562 if pycompat.oslinesep == b'\r\n' and line.endswith(b'\r'):
1562 line = line[:-1] 1563 line = line[:-1]