[PATCH 1 of 3] py3: conditionalize initialization of stdio flags

Yuya Nishihara yuya at tcha.org
Sat Mar 3 03:52:34 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1520046636 18000
#      Fri Mar 02 22:10:36 2018 -0500
# Node ID c0193f6ec467af81491d0e7c8c46fe0f676f3018
# Parent  a007db19dc4d889dda54014f8dd3eb8a1c1ef08b
py3: conditionalize initialization of stdio flags

Since Python 3 doesn't depend on the stdio of libc, there should be no need
to set O_BINARY flag on Windows.

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -105,12 +105,15 @@ def run():
         # change the status code and move on.
         except IOError:
             status = -1
-
     sys.exit(status & 255)
 
-def _initstdio():
-    for fp in (sys.stdin, sys.stdout, sys.stderr):
-        util.setbinary(fp)
+if pycompat.ispy3:
+    def _initstdio():
+        pass
+else:
+    def _initstdio():
+        for fp in (sys.stdin, sys.stdout, sys.stderr):
+            util.setbinary(fp)
 
 def _getsimilar(symbols, value):
     sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio()


More information about the Mercurial-devel mailing list