Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sivel/speedtest-cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2018-01-27 00:52:06 +0300
committerMatt Martz <matt@sivel.net>2018-01-27 00:52:06 +0300
commit2c847a1849e5c58bd21d3ea497133b0910bff1f8 (patch)
treeb29938026aafdc5ff38217eebb16b8bfb44e2a30
parente1bab1ab55470384e953cd8c4cf18b03c7082a21 (diff)
Add some guard code for places where sys.stdout and stderr are replaced with some other incompatible object
-rwxr-xr-xspeedtest.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/speedtest.py b/speedtest.py
index d7172e1..a3d3004 100755
--- a/speedtest.py
+++ b/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"""