py3: decode prompt string before calling rawinput
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 09 Oct 2019 15:28:16 +0200
changeset 43118 57efd5bd2ca2
parent 43117 8ff1ecfadcd1
child 43119 c9093ae8d6c4
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().
mercurial/ui.py
--- a/mercurial/ui.py	Tue Oct 08 15:06:18 2019 -0700
+++ b/mercurial/ui.py	Wed Oct 09 15:28:16 2019 +0200
@@ -1555,6 +1555,7 @@
         # - http://bugs.python.org/issue12833
         with self.timeblockedsection(b'stdio'):
             if usereadline:
+                prompt = encoding.strfromlocal(prompt)
                 line = encoding.strtolocal(pycompat.rawinput(prompt))
                 # When stdin is in binary mode on Windows, it can cause
                 # raw_input() to emit an extra trailing carriage return