changeset 36799:30742c216abb

ui: inline util.bytesinput() into ui._readline() Prepares for rework of Python 3 support, which is currently broken due to read-ahead buffer of TextIOWrapper.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 06 Mar 2018 02:14:11 -0600
parents cb0afaf112e8
children 15c050b5d599
files mercurial/ui.py mercurial/util.py
diffstat 2 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Tue Mar 06 02:05:25 2018 -0600
+++ b/mercurial/ui.py	Tue Mar 06 02:14:11 2018 -0600
@@ -1278,7 +1278,13 @@
         # prompt ' ' must exist; otherwise readline may delete entire line
         # - http://bugs.python.org/issue12833
         with self.timeblockedsection('stdio'):
-            line = util.bytesinput(self.fin, self.fout, r' ')
+            sin, sout = sys.stdin, sys.stdout
+            try:
+                sys.stdin = encoding.strio(self.fin)
+                sys.stdout = encoding.strio(self.fout)
+                line = encoding.strtolocal(pycompat.rawinput(r' '))
+            finally:
+                sys.stdin, sys.stdout = sin, sout
 
         # When stdin is in binary mode on Windows, it can cause
         # raw_input() to emit an extra trailing carriage return
--- a/mercurial/util.py	Tue Mar 06 02:05:25 2018 -0600
+++ b/mercurial/util.py	Tue Mar 06 02:14:11 2018 -0600
@@ -212,14 +212,6 @@
         return xs
     return _rapply(f, xs)
 
-def bytesinput(fin, fout, *args, **kwargs):
-    sin, sout = sys.stdin, sys.stdout
-    try:
-        sys.stdin, sys.stdout = encoding.strio(fin), encoding.strio(fout)
-        return encoding.strtolocal(pycompat.rawinput(*args, **kwargs))
-    finally:
-        sys.stdin, sys.stdout = sin, sout
-
 def bitsfrom(container):
     bits = 0
     for bit in container: