diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2021-08-07 09:45:20 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2021-08-07 09:45:20 +0200 |
commit | 7547cc311909c625835c0d5c0a90f490eaa5fe5d (patch) | |
tree | b4559303df5a05e6ec35683f8c95e15d2c924f83 | |
parent | 83699cf59c30191726448c6ca54ac3f0d18fe3b8 (diff) | |
download | cython-7547cc311909c625835c0d5c0a90f490eaa5fe5d.tar.gz |
Fix output encoding problems in the test runner with Py2.7 by not trying to decode the C compiler output and instead printing it unchanged as bytes.
-rwxr-xr-x | runtests.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/runtests.py b/runtests.py index d29c76890..5592792d6 100755 --- a/runtests.py +++ b/runtests.py @@ -1291,11 +1291,14 @@ class CythonCompileTestCase(unittest.TestCase): build_extension.run() except CompileError as exc: error = str(exc) - stderr = prepare_captured(get_stderr()) + stderr = get_stderr() if stderr: - print(u"Compiler output for module %s:\n%s" % (module, stderr)) + # The test module name should always be ASCII, but let's not risk encoding failures. + output = b"Compiler output for module %s:\n%s\n" % (module.encode('utf-8'), stderr) + out = sys.stdout if sys.version_info[0] == 2 else sys.stdout.buffer + out.write(output) if error is not None: - raise CompileError(u"%s\nCompiler output:\n%s" % (error, stderr)) + raise CompileError(u"%s\nCompiler output:\n%s" % (error, prepare_captured(stderr))) finally: os.chdir(cwd) |