Show More
@@ -131,17 +131,25 b' def _make_write_all(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 |
|
|
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() |
|
|||
143 | stdout = _make_write_all(sys.stdout.buffer) |
|
147 | stdout = _make_write_all(sys.stdout.buffer) | |
|
148 | if sys.stderr is None: | |||
|
149 | stderr = BadFile() | |||
|
150 | else: | |||
144 | stderr = _make_write_all(sys.stderr.buffer) |
|
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) |
@@ -49,6 +49,31 b' Writes to stdio succeed and fail appropr' | |||||
49 | [255] |
|
49 | [255] | |
50 | #endif |
|
50 | #endif | |
51 |
|
51 | |||
|
52 | On Python 3, stdio may be None: | |||
|
53 | ||||
|
54 | $ hg debuguiprompt --config ui.interactive=true 0<&- | |||
|
55 | abort: Bad file descriptor | |||
|
56 | [255] | |||
|
57 | $ hg version -q 0<&- | |||
|
58 | Mercurial Distributed SCM * (glob) | |||
|
59 | ||||
|
60 | #if py3 | |||
|
61 | $ hg version -q 1>&- | |||
|
62 | abort: Bad file descriptor | |||
|
63 | [255] | |||
|
64 | #else | |||
|
65 | $ hg version -q 1>&- | |||
|
66 | #endif | |||
|
67 | $ hg unknown -q 1>&- | |||
|
68 | hg: unknown command 'unknown' | |||
|
69 | (did you mean debugknown?) | |||
|
70 | [255] | |||
|
71 | ||||
|
72 | $ hg version -q 2>&- | |||
|
73 | Mercurial Distributed SCM * (glob) | |||
|
74 | $ hg unknown -q 2>&- | |||
|
75 | [255] | |||
|
76 | ||||
52 | $ hg commit -m test |
|
77 | $ hg commit -m test | |
53 |
|
78 | |||
54 | This command is ancient: |
|
79 | This command is ancient: |
General Comments 0
You need to be logged in to leave comments.
Login now