# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2020-12-02 08:49:09 # Node ID 7e1b4154cdca2381648790f8f03b965dbfa7e933 # Parent 81c1f5d1801f39fd29bcc920371032a92b8171d7 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 diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -187,15 +187,16 @@ if pycompat.ispy3: 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):