Show More
@@ -131,17 +131,25 b' def _make_write_all(stream):' | |||
|
131 | 131 | |
|
132 | 132 | |
|
133 | 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 | 137 | # TODO: .buffer might not exist if std streams were replaced; we'll need |
|
136 | 138 | # a silly wrapper to make a bytes stream backed by a unicode one. |
|
137 | 139 | |
|
138 |
|
|
|
139 | if sys.stdin: | |
|
140 | if sys.stdin is None: | |
|
141 | stdin = BadFile() | |
|
142 | else: | |
|
140 | 143 | stdin = sys.stdin.buffer |
|
144 | if sys.stdout is None: | |
|
145 | stdout = BadFile() | |
|
141 | 146 | else: |
|
142 | stdin = BadFile() | |
|
143 | 147 | stdout = _make_write_all(sys.stdout.buffer) |
|
148 | if sys.stderr is None: | |
|
149 | stderr = BadFile() | |
|
150 | else: | |
|
144 | 151 | stderr = _make_write_all(sys.stderr.buffer) |
|
152 | ||
|
145 | 153 | if pycompat.iswindows: |
|
146 | 154 | # Work around Windows bugs. |
|
147 | 155 | stdout = platform.winstdout(stdout) |
@@ -49,6 +49,31 b' Writes to stdio succeed and fail appropr' | |||
|
49 | 49 | [255] |
|
50 | 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 | 77 | $ hg commit -m test |
|
53 | 78 | |
|
54 | 79 | This command is ancient: |
General Comments 0
You need to be logged in to leave comments.
Login now