mercurial/utils/procutil.py
changeset 46175 a04c03b0678e
parent 46174 a1601ff3877c
child 46459 128a17d8436f
equal deleted inserted replaced
46174:a1601ff3877c 46175:a04c03b0678e
   129     # the data.
   129     # the data.
   130     return WriteAllWrapper(stream)
   130     return WriteAllWrapper(stream)
   131 
   131 
   132 
   132 
   133 if pycompat.ispy3:
   133 if pycompat.ispy3:
   134     # Python 3 implements its own I/O streams.
   134     # Python 3 implements its own I/O streams. Unlike stdio of C library,
       
   135     # sys.stdin/stdout/stderr may be None if underlying fd is closed.
       
   136 
   135     # TODO: .buffer might not exist if std streams were replaced; we'll need
   137     # TODO: .buffer might not exist if std streams were replaced; we'll need
   136     # a silly wrapper to make a bytes stream backed by a unicode one.
   138     # a silly wrapper to make a bytes stream backed by a unicode one.
   137 
   139 
   138     # sys.stdin can be None
   140     if sys.stdin is None:
   139     if sys.stdin:
   141         stdin = BadFile()
       
   142     else:
   140         stdin = sys.stdin.buffer
   143         stdin = sys.stdin.buffer
       
   144     if sys.stdout is None:
       
   145         stdout = BadFile()
   141     else:
   146     else:
   142         stdin = BadFile()
   147         stdout = _make_write_all(sys.stdout.buffer)
   143     stdout = _make_write_all(sys.stdout.buffer)
   148     if sys.stderr is None:
   144     stderr = _make_write_all(sys.stderr.buffer)
   149         stderr = BadFile()
       
   150     else:
       
   151         stderr = _make_write_all(sys.stderr.buffer)
       
   152 
   145     if pycompat.iswindows:
   153     if pycompat.iswindows:
   146         # Work around Windows bugs.
   154         # Work around Windows bugs.
   147         stdout = platform.winstdout(stdout)
   155         stdout = platform.winstdout(stdout)
   148         stderr = platform.winstdout(stderr)
   156         stderr = platform.winstdout(stderr)
   149     if isatty(stdout):
   157     if isatty(stdout):