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

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 8, 2020, 7:28 a.m.
Message ID <0285e852fcf28d9a44d7.1607412502@DESKTOP-STQPTJK>
Download mbox | patch
Permalink /patch/47832/
State Superseded
Headers show

Comments

Pulkit Goyal - Dec. 8, 2020, 7:28 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1606898949 -19800
#      Wed Dec 02 14:19:09 2020 +0530
# Node ID 0285e852fcf28d9a44d725fd737cbf031d308fe0
# Parent  6bab1270ddc9b7097a58de39afacb305f3364ea7
# 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 6bab1270ddc9 -r 0285e852fcf2 mercurial/dispatch.py
--- 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):