Patchwork [3,of,5,chg-tests-fix,V2] dispatch: disable line ending normalization on sys.stdin if its None

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 8, 2020, 1:42 p.m.
Message ID <4e205264bac2080164e4.1607434942@DESKTOP-STQPTJK>
Download mbox | patch
Permalink /patch/47837/
State New
Headers show

Comments

Pulkit Goyal - Dec. 8, 2020, 1:42 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1606898949 -19800
#      Wed Dec 02 14:19:09 2020 +0530
# Node ID 4e205264bac2080164e47137dbf991f09aa0f157
# Parent  f9776bf6ae3f3bb9073792ada2e3cba544e284dd
# EXP-Topic chg-test
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

Patch

diff -r f9776bf6ae3f -r 4e205264bac2 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Tue Dec 08 17:10:03 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):