# HG changeset patch # User Manuel Jacob # Date 1594368185 -7200 # Node ID 29a905fe23aeb90519cf8ac300c69a0b0cac805a # Parent 00cdac66961432877ec6da4a3495b41b65675899 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. diff -r 00cdac669614 -r 29a905fe23ae mercurial/utils/procutil.py --- 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)