##// END OF EJS Templates
procutil: distribute code for stdout...
Manuel Jacob -
r45653:63196198 default
parent child Browse files
Show More
@@ -81,32 +81,31 b' def make_line_buffered(stream):'
81
81
82
82
83 if pycompat.ispy3:
83 if pycompat.ispy3:
84 # Python 3 implements its own I/O streams.
84 # TODO: .buffer might not exist if std streams were replaced; we'll need
85 # TODO: .buffer might not exist if std streams were replaced; we'll need
85 # a silly wrapper to make a bytes stream backed by a unicode one.
86 # a silly wrapper to make a bytes stream backed by a unicode one.
86 stdin = sys.stdin.buffer
87 stdin = sys.stdin.buffer
87 stdout = sys.stdout.buffer
88 stdout = sys.stdout.buffer
88 stderr = sys.stderr.buffer
89 stderr = sys.stderr.buffer
90 if isatty(stdout):
91 # The standard library doesn't offer line-buffered binary streams.
92 stdout = make_line_buffered(stdout)
89 else:
93 else:
94 # Python 2 uses the I/O streams provided by the C library.
90 stdin = sys.stdin
95 stdin = sys.stdin
91 stdout = sys.stdout
96 stdout = sys.stdout
92 stderr = sys.stderr
97 stderr = sys.stderr
93
98 if isatty(stdout):
94 if isatty(stdout):
99 if pycompat.iswindows:
95 if pycompat.ispy3:
100 # Work around size limit when writing to console.
96 # Python 3 implements its own I/O streams.
101 stdout = platform.winstdout(stdout)
97 # The standard library doesn't offer line-buffered binary streams.
102 # The Windows C runtime library doesn't support line buffering.
98 stdout = make_line_buffered(stdout)
103 stdout = make_line_buffered(stdout)
99 elif pycompat.iswindows:
104 else:
100 # Work around size limit when writing to console.
105 # glibc determines buffering on first write to stdout - if we
101 stdout = platform.winstdout(stdout)
106 # replace a TTY destined stdout with a pipe destined stdout (e.g.
102 # Python 2 uses the I/O streams provided by the C library.
107 # pager), we want line buffering.
103 # The Windows C runtime library doesn't support line buffering.
108 stdout = os.fdopen(stdout.fileno(), 'wb', 1)
104 stdout = make_line_buffered(stdout)
105 else:
106 # glibc determines buffering on first write to stdout - if we
107 # replace a TTY destined stdout with a pipe destined stdout (e.g.
108 # pager), we want line buffering.
109 stdout = os.fdopen(stdout.fileno(), 'wb', 1)
110
109
111
110
112 findexe = platform.findexe
111 findexe = platform.findexe
General Comments 0
You need to be logged in to leave comments. Login now