diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2016-06-29 22:56:58 +0200 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2016-06-30 10:43:37 +0200 |
commit | e8d62711e6cbc3065ee5e6f6a654667f02a0bcd1 (patch) | |
tree | 8b3322a6025c29313e64c56f1204e124ce30ba6e | |
parent | 24194a6aed950ed4c3733e3c582abf8a15d98ffd (diff) | |
download | haskell-e8d62711e6cbc3065ee5e6f6a654667f02a0bcd1.tar.gz |
Testsuite: do not depend on sys.stdout.encoding
The cause of #12213 is in dump_stdout and dump_stderr:
print(read_no_crs(<filename>))
Commit 6f6f515401a29d26eaa5daae308b8e700abd4c04 changed read_no_crs to
return a unicode string. Printing a unicode strings works fine as long
as sys.stdout.encoding is 'UTF-8'.
There are two reasons why sys.stdout.encoding might not be 'UTF-8'.
* When output is going to a file, sys.stdout and sys.stdout do not respect
the locale:
$ LC_ALL=en_US.utf8 python -c 'import sys; print(sys.stderr.encoding)'
UTF-8
$ LC_ALL=en_US.utf8 python -c 'import sys; print(sys.stderr.encoding)' 2>/dev/null
None
* When output is going to the terminal, explicitly reopening sys.stdout has
the side-effect of changing sys.stdout.encoding from 'UTF-8' to 'None'.
sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w", 0)
We currently do this to set a buffersize of 0 (the actual
buffersize used is irrelevant for the sys.stdout.encoding problem).
Solution: fix dump_stdout and dump_stderr to not use read_no_crs.
-rw-r--r-- | testsuite/driver/testlib.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index 493e52b0a2..595baabb3b 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -1366,7 +1366,7 @@ def stdout_ok(name, way): def dump_stdout( name ): print('Stdout:') - print(read_no_crs(in_testdir(name, 'run.stdout'))) + print(open(in_testdir(name, 'run.stdout')).read()) def stderr_ok(name, way): actual_stderr_file = add_suffix(name, 'run.stderr') @@ -1379,7 +1379,7 @@ def stderr_ok(name, way): def dump_stderr( name ): print("Stderr:") - print(read_no_crs(in_testdir(name, 'run.stderr'))) + print(open(in_testdir(name, 'run.stderr')).read()) def read_no_crs(file): str = '' |