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