Skip to content

Commit 1ca7bd7

Browse files
author
Nathan Hawes
authored
Merge pull request #345 from nathawes/dont-output-unicode-to-ascii-tty
[run_sk_stress_test] Replace non-ascii characters when outputting to an ascii tty
2 parents ba7650b + d42e155 commit 1ca7bd7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

run_sk_stress_test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import json
2121
import subprocess
2222
import argparse
2323
import platform
24+
import codecs
2425

2526
import common
2627

@@ -337,6 +338,14 @@ class StressTesterRunner(object):
337338
except OSError:
338339
pass
339340

341+
if os.isatty(sys.stdout.fileno()):
342+
encoding = sys.stdout.encoding
343+
errors = 'replace'
344+
else:
345+
encoding = 'utf-8'
346+
errors = None
347+
sys.stdout = codecs.getwriter(encoding)(sys.stdout, errors=errors)
348+
340349
if __name__ == '__main__':
341350
sys.exit(main())
342351

0 commit comments

Comments
 (0)