aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mtest.py
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2019-01-04 08:42:01 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2019-01-06 19:55:55 -0500
commit7993747e139744fe6c8fb0f5cd324627629ec970 (patch)
tree0936d7cf584d9c52d8c1ee0db85ad7d1b2bb83a0 /mesonbuild/mtest.py
parent3232f780d8c3baba0cbca3f9fea18d1a722bf957 (diff)
downloadmeson-7993747e139744fe6c8fb0f5cd324627629ec970.zip
meson-7993747e139744fe6c8fb0f5cd324627629ec970.tar.gz
meson-7993747e139744fe6c8fb0f5cd324627629ec970.tar.bz2
Save surrogates as-is in log files
When python sees an invalid character in a filename for the current locale, instead of clobbering it, it saves is as an invalid codepoint called a surrogate. We need to explicitly instruct the encoder to write those out as-is. In the JSON file, we replace them instead to produce valid json.
Diffstat (limited to 'mesonbuild/mtest.py')
-rw-r--r--mesonbuild/mtest.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 8ce9538..b4bd4f2 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -647,8 +647,8 @@ Timeout: %4d
self.logfilename = logfile_base + '.txt'
self.jsonlogfilename = logfile_base + '.json'
- self.jsonlogfile = open(self.jsonlogfilename, 'w', encoding='utf-8')
- self.logfile = open(self.logfilename, 'w', encoding='utf-8')
+ self.jsonlogfile = open(self.jsonlogfilename, 'w', encoding='utf-8', errors='replace')
+ self.logfile = open(self.logfilename, 'w', encoding='utf-8', errors='surrogateescape')
self.logfile.write('Log of Meson test suite run on %s\n\n'
% datetime.datetime.now().isoformat())