##// END OF EJS Templates
dispatch: gate against missing stdout/stderr...
Yuya Nishihara -
r46789:a9765e0a default
parent child Browse files
Show More
@@ -166,6 +166,7 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 if sys.stdout is not None:
169 # write_through is new in Python 3.7.
170 # write_through is new in Python 3.7.
170 kwargs = {
171 kwargs = {
171 "newline": "\n",
172 "newline": "\n",
@@ -174,9 +175,13 b' if pycompat.ispy3:'
174 if util.safehasattr(sys.stdout, "write_through"):
175 if util.safehasattr(sys.stdout, "write_through"):
175 kwargs["write_through"] = sys.stdout.write_through
176 kwargs["write_through"] = sys.stdout.write_through
176 sys.stdout = io.TextIOWrapper(
177 sys.stdout = io.TextIOWrapper(
177 sys.stdout.buffer, sys.stdout.encoding, sys.stdout.errors, **kwargs
178 sys.stdout.buffer,
179 sys.stdout.encoding,
180 sys.stdout.errors,
181 **kwargs
178 )
182 )
179
183
184 if sys.stderr is not None:
180 kwargs = {
185 kwargs = {
181 "newline": "\n",
186 "newline": "\n",
182 "line_buffering": sys.stderr.line_buffering,
187 "line_buffering": sys.stderr.line_buffering,
@@ -184,7 +189,10 b' if pycompat.ispy3:'
184 if util.safehasattr(sys.stderr, "write_through"):
189 if util.safehasattr(sys.stderr, "write_through"):
185 kwargs["write_through"] = sys.stderr.write_through
190 kwargs["write_through"] = sys.stderr.write_through
186 sys.stderr = io.TextIOWrapper(
191 sys.stderr = io.TextIOWrapper(
187 sys.stderr.buffer, sys.stderr.encoding, sys.stderr.errors, **kwargs
192 sys.stderr.buffer,
193 sys.stderr.encoding,
194 sys.stderr.errors,
195 **kwargs
188 )
196 )
189
197
190 if sys.stdin is not None:
198 if sys.stdin is not None:
@@ -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