Show More
@@ -166,26 +166,34 b' if pycompat.ispy3:' | |||
|
166 | 166 | # "just work," here we change the sys.* streams to disable line ending |
|
167 | 167 | # normalization, ensuring compatibility with our ui type. |
|
168 | 168 | |
|
169 | # write_through is new in Python 3.7. | |
|
170 | kwargs = { | |
|
171 | "newline": "\n", | |
|
172 | "line_buffering": sys.stdout.line_buffering, | |
|
173 | } | |
|
174 | if util.safehasattr(sys.stdout, "write_through"): | |
|
175 | kwargs["write_through"] = sys.stdout.write_through | |
|
176 | sys.stdout = io.TextIOWrapper( | |
|
177 | sys.stdout.buffer, sys.stdout.encoding, sys.stdout.errors, **kwargs | |
|
178 | ) | |
|
169 | if sys.stdout is not None: | |
|
170 | # write_through is new in Python 3.7. | |
|
171 | kwargs = { | |
|
172 | "newline": "\n", | |
|
173 | "line_buffering": sys.stdout.line_buffering, | |
|
174 | } | |
|
175 | if util.safehasattr(sys.stdout, "write_through"): | |
|
176 | kwargs["write_through"] = sys.stdout.write_through | |
|
177 | sys.stdout = io.TextIOWrapper( | |
|
178 | sys.stdout.buffer, | |
|
179 | sys.stdout.encoding, | |
|
180 | sys.stdout.errors, | |
|
181 | **kwargs | |
|
182 | ) | |
|
179 | 183 | |
|
180 | kwargs = { | |
|
181 | "newline": "\n", | |
|
182 | "line_buffering": sys.stderr.line_buffering, | |
|
183 | } | |
|
184 | if util.safehasattr(sys.stderr, "write_through"): | |
|
185 | kwargs["write_through"] = sys.stderr.write_through | |
|
186 | sys.stderr = io.TextIOWrapper( | |
|
187 | sys.stderr.buffer, sys.stderr.encoding, sys.stderr.errors, **kwargs | |
|
188 | ) | |
|
184 | if sys.stderr is not None: | |
|
185 | kwargs = { | |
|
186 | "newline": "\n", | |
|
187 | "line_buffering": sys.stderr.line_buffering, | |
|
188 | } | |
|
189 | if util.safehasattr(sys.stderr, "write_through"): | |
|
190 | kwargs["write_through"] = sys.stderr.write_through | |
|
191 | sys.stderr = io.TextIOWrapper( | |
|
192 | sys.stderr.buffer, | |
|
193 | sys.stderr.encoding, | |
|
194 | sys.stderr.errors, | |
|
195 | **kwargs | |
|
196 | ) | |
|
189 | 197 | |
|
190 | 198 | if sys.stdin is not None: |
|
191 | 199 | # No write_through on read-only stream. |
@@ -200,6 +208,8 b' if pycompat.ispy3:' | |||
|
200 | 208 | |
|
201 | 209 | def _silencestdio(): |
|
202 | 210 | for fp in (sys.stdout, sys.stderr): |
|
211 | if fp is None: | |
|
212 | continue | |
|
203 | 213 | # Check if the file is okay |
|
204 | 214 | try: |
|
205 | 215 | fp.flush() |
General Comments 0
You need to be logged in to leave comments.
Login now