changeset 46084:7e1b4154cdca

dispatch: disable line ending normalization on sys.stdin if its None Fixes test-chg.t on python 3 with chg. Differential Revision: https://phab.mercurial-scm.org/D9501
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 02 Dec 2020 14:19:09 +0530
parents 81c1f5d1801f
children e0866c047e64
files mercurial/dispatch.py
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Wed Dec 02 13:55:17 2020 +0530
+++ b/mercurial/dispatch.py	Wed Dec 02 14:19:09 2020 +0530
@@ -187,15 +187,16 @@
             sys.stderr.buffer, sys.stderr.encoding, sys.stderr.errors, **kwargs
         )
 
-        # No write_through on read-only stream.
-        sys.stdin = io.TextIOWrapper(
-            sys.stdin.buffer,
-            sys.stdin.encoding,
-            sys.stdin.errors,
-            # None is universal newlines mode.
-            newline=None,
-            line_buffering=sys.stdin.line_buffering,
-        )
+        if sys.stdin is not None:
+            # No write_through on read-only stream.
+            sys.stdin = io.TextIOWrapper(
+                sys.stdin.buffer,
+                sys.stdin.encoding,
+                sys.stdin.errors,
+                # None is universal newlines mode.
+                newline=None,
+                line_buffering=sys.stdin.line_buffering,
+            )
 
     def _silencestdio():
         for fp in (sys.stdout, sys.stderr):