[PATCH] procutil: back out 8403cc54bc83 (make ....procutil.stderr unbuffered)
# HG changeset patch
# User Manuel Jacob <[hidden email]>
# Date 1594440202 -7200
# Sat Jul 11 06:03:22 2020 +0200
# Node ID 7bf3570f54114b6298a1b35108c210ca684cc183
# Parent c49e8aadd06eb715732fcc23713bc9de949381b1
# EXP-Topic stdio
procutil: back out 8403cc54bc83 (make ....procutil.stderr unbuffered)
Changeset 8403cc54bc83 introduced code that opens a second file object
referring to the stderr file descriptor. This broke tests on Windows. The
reason is that on Windows, sys.stderr is buffered and procutil.stderr closed
the file descriptor when it got garbage collected before sys.stderr had the
chance to flush buffered data.
`procutil.stdout` had the same problem for a long time, but we didn’t realize,
as in CI test runs, stdout is not a TTY and in this case no second file object
-# stderr should be unbuffered
- # On Python 3, buffered streams may expose an underlying raw stream. This is
- # definitively the case for the streams initialized by the interpreter. If
- # the attribute isn't present, the stream is already unbuffered or doesn't
- # expose an underlying raw stream, in which case we use the stream as-is.
- stderr = getattr(stderr, 'raw', stderr)
- # On Windows, stderr is buffered at least when connected to a pipe.
- stderr = os.fdopen(stderr.fileno(), 'wb', 0)
-# On other platforms, stderr is always unbuffered.