##// END OF EJS Templates
procutil: define LineBufferedWrapper on all Python versions...
Manuel Jacob -
r45584:2bfbd7d2 default
parent child Browse files
Show More
@@ -49,23 +49,22 b' def isatty(fp):'
49 return False
49 return False
50
50
51
51
52 if pycompat.ispy3:
52 class LineBufferedWrapper(object):
53 def __init__(self, orig):
54 self.orig = orig
53
55
54 class LineBufferedWrapper(object):
56 def __getattr__(self, attr):
55 def __init__(self, orig):
57 return getattr(self.orig, attr)
56 self.orig = orig
57
58 def __getattr__(self, attr):
59 return getattr(self.orig, attr)
60
58
61 def write(self, s):
59 def write(self, s):
62 orig = self.orig
60 orig = self.orig
63 res = orig.write(s)
61 res = orig.write(s)
64 if s.endswith(b'\n'):
62 if s.endswith(b'\n'):
65 orig.flush()
63 orig.flush()
66 return res
64 return res
67
65
68 io.BufferedIOBase.register(LineBufferedWrapper)
66
67 io.BufferedIOBase.register(LineBufferedWrapper)
69
68
70
69
71 # glibc determines buffering on first write to stdout - if we replace a TTY
70 # glibc determines buffering on first write to stdout - if we replace a TTY
General Comments 0
You need to be logged in to leave comments. Login now