mercurial/utils/procutil.py
changeset 45103 a5fa2761a6cd
parent 45095 8e04607023e5
child 45148 a37f290a7124
equal deleted inserted replaced
45102:efcc87d37f4d 45103:a5fa2761a6cd
    98 
    98 
    99 
    99 
   100 io.IOBase.register(WriteAllWrapper)
   100 io.IOBase.register(WriteAllWrapper)
   101 
   101 
   102 
   102 
   103 def make_write_all(stream):
   103 def _make_write_all(stream):
   104     assert pycompat.ispy3
   104     assert pycompat.ispy3
   105     if isinstance(stream, WriteAllWrapper):
   105     if isinstance(stream, WriteAllWrapper):
   106         return stream
   106         return stream
   107     if isinstance(stream, io.BufferedIOBase):
   107     if isinstance(stream, io.BufferedIOBase):
   108         # The io.BufferedIOBase.write() contract guarantees that all data is
   108         # The io.BufferedIOBase.write() contract guarantees that all data is
   116 if pycompat.ispy3:
   116 if pycompat.ispy3:
   117     # Python 3 implements its own I/O streams.
   117     # Python 3 implements its own I/O streams.
   118     # TODO: .buffer might not exist if std streams were replaced; we'll need
   118     # TODO: .buffer might not exist if std streams were replaced; we'll need
   119     # a silly wrapper to make a bytes stream backed by a unicode one.
   119     # a silly wrapper to make a bytes stream backed by a unicode one.
   120     stdin = sys.stdin.buffer
   120     stdin = sys.stdin.buffer
   121     stdout = make_write_all(sys.stdout.buffer)
   121     stdout = _make_write_all(sys.stdout.buffer)
   122     if isatty(stdout):
   122     if isatty(stdout):
   123         # The standard library doesn't offer line-buffered binary streams.
   123         # The standard library doesn't offer line-buffered binary streams.
   124         stdout = make_line_buffered(stdout)
   124         stdout = make_line_buffered(stdout)
   125     stderr = make_write_all(sys.stderr.buffer)
   125     stderr = _make_write_all(sys.stderr.buffer)
   126 else:
   126 else:
   127     # Python 2 uses the I/O streams provided by the C library.
   127     # Python 2 uses the I/O streams provided by the C library.
   128     stdin = sys.stdin
   128     stdin = sys.stdin
   129     stdout = sys.stdout
   129     stdout = sys.stdout
   130     if isatty(stdout):
   130     if isatty(stdout):