Add some guard code for places where sys.stdout and stderr are replaced with some other incompatible object
This commit is contained in:
parent
e1bab1ab55
commit
2c847a1849
|
@ -165,8 +165,14 @@ except ImportError:
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
_py3_print = getattr(builtins, 'print')
|
_py3_print = getattr(builtins, 'print')
|
||||||
|
try:
|
||||||
_py3_utf8_stdout = _Py3Utf8Output(sys.stdout)
|
_py3_utf8_stdout = _Py3Utf8Output(sys.stdout)
|
||||||
_py3_utf8_stderr = _Py3Utf8Output(sys.stderr)
|
_py3_utf8_stderr = _Py3Utf8Output(sys.stderr)
|
||||||
|
except OSError:
|
||||||
|
# sys.stdout/sys.stderr is not a compatible stdout/stderr object
|
||||||
|
# just use it and hope things go ok
|
||||||
|
_py3_utf8_stdout = sys.stdout
|
||||||
|
_py3_utf8_stderr = sys.stderr
|
||||||
|
|
||||||
def to_utf8(v):
|
def to_utf8(v):
|
||||||
"""No-op encode to utf-8 for py3"""
|
"""No-op encode to utf-8 for py3"""
|
||||||
|
|
Loading…
Reference in New Issue