Patchwork [03,of,11,V2] procutil: explain better why line buffering is not possible

login
register
mail settings
Submitter Manuel Jacob
Date July 12, 2020, 10:41 p.m.
Message ID <ba4ec481948de77e36c8.1594593688@tmp>
Download mbox | patch
Permalink /patch/46707/
State Accepted
Headers show

Comments

Manuel Jacob - July 12, 2020, 10:41 p.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1594367738 -7200
#      Fri Jul 10 09:55:38 2020 +0200
# Node ID ba4ec481948de77e36c8267f1acf5b904efba761
# Parent  a0ddc1349dde0f5849d196236c3fa31d49934511
# EXP-Topic stdio
procutil: explain better why line buffering is not possible

The sentence “On Python 3, buffered binary streams can't be set line-buffered.”
was imprecise, as all streams are just Python classes and we can implement our
own (which we did).

Patch

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -120,9 +120,10 @@ 
 # buffering.
 if isatty(stdout):
     if pycompat.ispy3 or pycompat.iswindows:
-        # On Python 3, buffered binary streams can't be set line-buffered.
-        # On Python 2, Windows doesn't support line buffering.
-        # Therefore we have a wrapper that implements line buffering.
+        # Python 3 implements its own I/O streams.
+        # The standard library doesn't offer line-buffered binary streams.
+        # 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)
     else:
         stdout = reopen_stream(stdout, 'wb', 1)