##// END OF EJS Templates
py3: make encoding.strio() an identity function on Python 2...
Yuya Nishihara -
r33852:f18b1153 default
parent child Browse files
Show More
@@ -575,15 +575,17 b' def fromutf8b(s):'
575 575 r += c
576 576 return r
577 577
578 if pycompat.ispy3:
578 579 class strio(io.TextIOWrapper):
579 580 """Wrapper around TextIOWrapper that respects hg's encoding assumptions.
580 581
581 582 Also works around Python closing streams.
582 583 """
583 584
584 def __init__(self, buffer, **kwargs):
585 kwargs[r'encoding'] = _sysstr(encoding)
586 super(strio, self).__init__(buffer, **kwargs)
585 def __init__(self, buffer):
586 super(strio, self).__init__(buffer, encoding=_sysstr(encoding))
587 587
588 588 def __del__(self):
589 589 """Override __del__ so it doesn't close the underlying stream."""
590 else:
591 strio = pycompat.identity
@@ -175,11 +175,10 b' def safehasattr(thing, attr):'
175 175 def bytesinput(fin, fout, *args, **kwargs):
176 176 sin, sout = sys.stdin, sys.stdout
177 177 try:
178 sys.stdin, sys.stdout = encoding.strio(fin), encoding.strio(fout)
178 179 if pycompat.ispy3:
179 sys.stdin, sys.stdout = encoding.strio(fin), encoding.strio(fout)
180 180 return encoding.strtolocal(input(*args, **kwargs))
181 181 else:
182 sys.stdin, sys.stdout = fin, fout
183 182 return raw_input(*args, **kwargs)
184 183 finally:
185 184 sys.stdin, sys.stdout = sin, sout
General Comments 0
You need to be logged in to leave comments. Login now