# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2020-12-10 08:33:46 # Node ID 7ce24d3761e8bd09b0d3772c66ab435fc472051c # Parent 49b6910217f907ef75069f70eb4c7c392418b11a procutil: don't assign stdin to None, use os.devnull instead It will be painful to take care of procutil.stdin being None everywhere. Thanks to Yuya who recommended it. diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -126,7 +126,11 @@ if pycompat.ispy3: # a silly wrapper to make a bytes stream backed by a unicode one. # sys.stdin can be None - stdin = sys.stdin.buffer if sys.stdin else sys.stdin + if sys.stdin: + stdin = sys.stdin.buffer + else: + stdin = open(os.devnull, 'rb') + os.close(stdin.fileno()) stdout = _make_write_all(sys.stdout.buffer) stderr = _make_write_all(sys.stderr.buffer) if pycompat.iswindows: