From 414aee63285585e94bbb8d10c26f0aceb7fa60ca Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 20 Nov 2020 09:07:03 +0100 Subject: [PATCH] mtest: use backslash replace when printing error logs If there's an UnicodeEncodeError while printing the error logs, TestHarness tries an encode/decode pair to get rid of anything that is not a 7-bit ASCII character; this however results in "?" characters that are not very clear. To make it easier to understand what is going on, use backslashreplace instead. While at it, fix the decode to use a matching encoding. This will only matter in the rare case of sys.stdout.encoding not being an ASCII superset, but that should not matter. Signed-off-by: Paolo Bonzini --- mesonbuild/mtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index b8db80d89..acd361225 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -1050,7 +1050,7 @@ class TestHarness: try: print(line) except UnicodeEncodeError: - line = line.encode('ascii', errors='replace').decode() + line = line.encode('ascii', errors='backslashreplace').decode('ascii') print(line) def total_failure_count(self) -> int: