From b4a2ad6d11e2eb1f95e90bb5a487adb9087a9dfa Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 30 Oct 2015 14:58:58 -0700 Subject: [PATCH] bug 2199 postfix: make unicode decode() more robust --- test.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index e12347dfc..dd4c82afa 100755 --- a/test.py +++ b/test.py @@ -767,8 +767,18 @@ def run_job_synchronously(shell_command, directory, valgrind, is_python, build_p elapsed_time = time.time() - start_time retval = proc.returncode - stdout_results = stdout_results.decode() - stderr_results = stderr_results.decode() + try: + stdout_results = stdout_results.decode() + except UnicodeDecodeError: + print("Non-decodable character in stdout output of %s" % cmd) + print(stdout_results) + retval = 1 + try: + stderr_results = stderr_results.decode() + except UnicodeDecodeError: + print("Non-decodable character in stderr output of %s" % cmd) + print(stderr_results) + retval = 1 # # valgrind sometimes has its own idea about what kind of memory management