##// END OF EJS Templates
procutil: make mercurial.utils.procutil.stderr unbuffered...
Manuel Jacob -
r45590:8403cc54 default
parent child Browse files
Show More
@@ -99,6 +99,18 b' if isatty(stdout):'
99 99 else:
100 100 stdout = os.fdopen(stdout.fileno(), 'wb', 1)
101 101
102 # stderr should be unbuffered
103 if pycompat.ispy3:
104 # On Python 3, buffered streams may expose an underlying raw stream. This is
105 # definitively the case for the streams initialized by the interpreter. If
106 # the attribute isn't present, the stream is already unbuffered or doesn't
107 # expose an underlying raw stream, in which case we use the stream as-is.
108 stderr = getattr(stderr, 'raw', stderr)
109 elif pycompat.iswindows:
110 # On Windows, stderr is buffered at least when connected to a pipe.
111 stderr = os.fdopen(stderr.fileno(), 'wb', 0)
112 # On other platforms, stderr is always unbuffered.
113
102 114
103 115 findexe = platform.findexe
104 116 _gethgcmd = platform.gethgcmd
@@ -100,6 +100,18 b' class TestStdio(unittest.TestCase):'
100 100 test_stdout_ptys_unbuffered
101 101 )
102 102
103 def test_stderr_pipes(self):
104 self._test('stderr', _pipes, UNBUFFERED)
105
106 def test_stderr_ptys(self):
107 self._test('stderr', _ptys, UNBUFFERED)
108
109 def test_stderr_pipes_unbuffered(self):
110 self._test('stderr', _pipes, UNBUFFERED, python_args=['-u'])
111
112 def test_stderr_ptys_unbuffered(self):
113 self._test('stderr', _ptys, UNBUFFERED, python_args=['-u'])
114
103 115
104 116 if __name__ == '__main__':
105 117 import silenttestrunner
General Comments 0
You need to be logged in to leave comments. Login now