Patchwork D9501: dispatch: disable line ending normalization on sys.stdin if its None

login
register
mail settings
Submitter phabricator
Date Dec. 2, 2020, 6:08 p.m.
Message ID <differential-rev-PHID-DREV-s3urz675zzwjfvm54b7i-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47783/
State Superseded
Headers show

Comments

phabricator - Dec. 2, 2020, 6:08 p.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Fixes test-chg.t on python 3 with chg.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D9501

AFFECTED FILES
  mercurial/dispatch.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -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):