# HG changeset patch
# User Denis Laxalde <denis.laxa...@logilab.fr>
# Date 1570627696 -7200
#      Wed Oct 09 15:28:16 2019 +0200
# Node ID 99f06850be3ecc521ba461684686865c1191c5a0
# Parent  1fcf79e9943a17a2e7ae19954b2b5ad5972f8fff
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().

diff --git a/mercurial/ui.py b/mercurial/ui.py
index b8cac79..432f53e 100644
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1555,6 +1555,7 @@ class ui(object):
         # - 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
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to