Mercurial > hg
changeset 33853:cfcfbe6c96f8
py3: select input or raw_input by pycompat
This seems slightly cleaner.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 16 Aug 2017 13:54:24 +0900 |
parents | f18b11534274 |
children | f6dc30b83432 |
files | mercurial/pycompat.py mercurial/util.py |
diffstat | 2 files changed, 3 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/pycompat.py Wed Aug 16 13:50:11 2017 +0900 +++ b/mercurial/pycompat.py Wed Aug 16 13:54:24 2017 +0900 @@ -63,6 +63,7 @@ sysexecutable = os.fsencode(sysexecutable) stringio = io.BytesIO maplist = lambda *args: list(map(*args)) + rawinput = input # TODO: .buffer might not exist if std streams were replaced; we'll need # a silly wrapper to make a bytes stream backed by a unicode one. @@ -312,6 +313,7 @@ shlexsplit = shlex.split stringio = cStringIO.StringIO maplist = map + rawinput = raw_input class _pycompatstub(object): def __init__(self):
--- a/mercurial/util.py Wed Aug 16 13:50:11 2017 +0900 +++ b/mercurial/util.py Wed Aug 16 13:54:24 2017 +0900 @@ -176,10 +176,7 @@ sin, sout = sys.stdin, sys.stdout try: sys.stdin, sys.stdout = encoding.strio(fin), encoding.strio(fout) - if pycompat.ispy3: - return encoding.strtolocal(input(*args, **kwargs)) - else: - return raw_input(*args, **kwargs) + return encoding.strtolocal(pycompat.rawinput(*args, **kwargs)) finally: sys.stdin, sys.stdout = sin, sout