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
--- 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):