mirror of
https://github.com/sivel/speedtest-cli.git
synced 2026-08-04 14:49:36 +00:00
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
1 changed files with 8 additions and 2 deletions
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…
Add table
Add a link
Reference in a new issue