From patchwork Wed Dec 2 18:08:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9501: dispatch: disable line ending normalization on sys.stdin if its None From: phabricator X-Patchwork-Id: 47783 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Wed, 2 Dec 2020 18:08:12 +0000 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 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):