procutil: use mercurial.windows.winstdout only on Python 2 and TTYs
Python 3 already works around the bug. The workaround is only needed when
writing to consoles. If stdout is a console, sys.stdout.isatty() is true.
--- a/mercurial/utils/procutil.py Fri Jul 10 09:59:36 2020 +0200
+++ b/mercurial/utils/procutil.py Fri Jul 10 10:03:05 2020 +0200
@@ -91,9 +91,6 @@
stdout = sys.stdout
stderr = sys.stderr
-if pycompat.iswindows:
- stdout = platform.winstdout(stdout)
-
# glibc determines buffering on first write to stdout - if we replace a TTY
# destined stdout with a pipe destined stdout (e.g. pager), we want line
# buffering.
@@ -103,6 +100,8 @@
# The standard library doesn't offer line-buffered binary streams.
stdout = make_line_buffered(stdout)
elif pycompat.iswindows:
+ # Work around size limit when writing to console.
+ stdout = platform.winstdout(stdout)
# Python 2 uses the I/O streams provided by the C library.
# The Windows C runtime library doesn't support line buffering.
stdout = make_line_buffered(stdout)