Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 36791: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 | 1fbbb8e83392 |
children | eca1051e6c22 |
comparison
equal
deleted
inserted
replaced
36790:cb0afaf112e8 | 36791:30742c216abb |
---|---|
209 """ | 209 """ |
210 if f is pycompat.identity: | 210 if f is pycompat.identity: |
211 # fast path mainly for py2 | 211 # fast path mainly for py2 |
212 return xs | 212 return xs |
213 return _rapply(f, xs) | 213 return _rapply(f, xs) |
214 | |
215 def bytesinput(fin, fout, *args, **kwargs): | |
216 sin, sout = sys.stdin, sys.stdout | |
217 try: | |
218 sys.stdin, sys.stdout = encoding.strio(fin), encoding.strio(fout) | |
219 return encoding.strtolocal(pycompat.rawinput(*args, **kwargs)) | |
220 finally: | |
221 sys.stdin, sys.stdout = sin, sout | |
222 | 214 |
223 def bitsfrom(container): | 215 def bitsfrom(container): |
224 bits = 0 | 216 bits = 0 |
225 for bit in container: | 217 for bit in container: |
226 bits |= bit | 218 bits |= bit |