comparison mercurial/utils/procutil.py @ 46102:7ce24d3761e8

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.
author Pulkit Goyal <7895pulkit@gmail.com>
date Thu, 10 Dec 2020 14:03:46 +0530
parents 81c1f5d1801f
children a1601ff3877c
comparison
equal deleted inserted replaced
46101:49b6910217f9 46102:7ce24d3761e8
124 # Python 3 implements its own I/O streams. 124 # Python 3 implements its own I/O streams.
125 # TODO: .buffer might not exist if std streams were replaced; we'll need 125 # TODO: .buffer might not exist if std streams were replaced; we'll need
126 # a silly wrapper to make a bytes stream backed by a unicode one. 126 # a silly wrapper to make a bytes stream backed by a unicode one.
127 127
128 # sys.stdin can be None 128 # sys.stdin can be None
129 stdin = sys.stdin.buffer if sys.stdin else sys.stdin 129 if sys.stdin:
130 stdin = sys.stdin.buffer
131 else:
132 stdin = open(os.devnull, 'rb')
133 os.close(stdin.fileno())
130 stdout = _make_write_all(sys.stdout.buffer) 134 stdout = _make_write_all(sys.stdout.buffer)
131 stderr = _make_write_all(sys.stderr.buffer) 135 stderr = _make_write_all(sys.stderr.buffer)
132 if pycompat.iswindows: 136 if pycompat.iswindows:
133 # Work around Windows bugs. 137 # Work around Windows bugs.
134 stdout = platform.winstdout(stdout) 138 stdout = platform.winstdout(stdout)