Patchwork [2,of,5,V3] procutil: move assignments

login
register
mail settings
Submitter Manuel Jacob
Date July 14, 2020, 6:41 p.m.
Message ID <268bf1717fd324a58a5c.1594752108@tmp>
Download mbox | patch
Permalink /patch/46743/
State Accepted
Headers show

Comments

Manuel Jacob - July 14, 2020, 6:41 p.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1594446424 -7200
#      Sat Jul 11 07:47:04 2020 +0200
# Node ID 268bf1717fd324a58a5ce1d2d70d2f8cd512cc39
# Parent  6f0e5c118bfd96a56bd761d8a3ec85e9d1c9e1e8
# EXP-Topic stdio
procutil: move assignments

This should probably be part of the previous patch, but folding it results in a
less useful word diff, so I decided to keep it separate for review.

Patch

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -86,15 +86,14 @@ 
     # a silly wrapper to make a bytes stream backed by a unicode one.
     stdin = sys.stdin.buffer
     stdout = sys.stdout.buffer
-    stderr = sys.stderr.buffer
     if isatty(stdout):
         # The standard library doesn't offer line-buffered binary streams.
         stdout = make_line_buffered(stdout)
+    stderr = sys.stderr.buffer
 else:
     # Python 2 uses the I/O streams provided by the C library.
     stdin = sys.stdin
     stdout = sys.stdout
-    stderr = sys.stderr
     if isatty(stdout):
         if pycompat.iswindows:
             # Work around size limit when writing to console.
@@ -106,6 +105,7 @@ 
             # replace a TTY destined stdout with a pipe destined stdout (e.g.
             # pager), we want line buffering.
             stdout = os.fdopen(stdout.fileno(), 'wb', 1)
+    stderr = sys.stderr
 
 
 findexe = platform.findexe