mercurial/util.py
changeset 33839 7d5bc0e5b88f
parent 33820 fa7e30efe05a
child 33852 f18b11534274
--- a/mercurial/util.py	Wed Jul 26 23:33:26 2017 -0400
+++ b/mercurial/util.py	Mon Jul 24 14:38:40 2017 -0400
@@ -172,6 +172,18 @@
 def safehasattr(thing, attr):
     return getattr(thing, attr, _notset) is not _notset
 
+def bytesinput(fin, fout, *args, **kwargs):
+    sin, sout = sys.stdin, sys.stdout
+    try:
+        if pycompat.ispy3:
+            sys.stdin, sys.stdout = encoding.strio(fin), encoding.strio(fout)
+            return encoding.strtolocal(input(*args, **kwargs))
+        else:
+            sys.stdin, sys.stdout = fin, fout
+            return raw_input(*args, **kwargs)
+    finally:
+        sys.stdin, sys.stdout = sin, sout
+
 def bitsfrom(container):
     bits = 0
     for bit in container: