Browse Source

Add some guard code for places where sys.stdout and stderr are replaced with some other incompatible object

pull/380/merge
Matt Martz 5 years ago
parent
commit
2c847a1849
  1. 10
      speedtest.py

10
speedtest.py

@ -165,8 +165,14 @@ except ImportError:
self.flush()
_py3_print = getattr(builtins, 'print')
_py3_utf8_stdout = _Py3Utf8Output(sys.stdout)
_py3_utf8_stderr = _Py3Utf8Output(sys.stderr)
try:
_py3_utf8_stdout = _Py3Utf8Output(sys.stdout)
_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):
"""No-op encode to utf-8 for py3"""

Loading…
Cancel
Save