From 5f966b0b8d61e2abf003439b2f93a9bd19be798c Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 7 Nov 2020 08:41:42 +0100 Subject: Always pass an encoding to open() using text mode Otherwise we'll end up using the locale encoding. While it's usually utf-8, that's not the case on Windows. There is one place where a file with filenames is passed, not sure there so I left it and passed a explicit None. --- giscanner/dumper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'giscanner/dumper.py') diff --git a/giscanner/dumper.py b/giscanner/dumper.py index e4b6ea03..f61c46c1 100644 --- a/giscanner/dumper.py +++ b/giscanner/dumper.py @@ -111,13 +111,13 @@ class DumpCompiler(object): 'gobject-introspection-1.0', 'gdump.c') if not os.path.isfile(gdump_path): raise SystemExit("Couldn't find %r" % (gdump_path, )) - with open(gdump_path) as gdump_file: + with open(gdump_path, encoding='utf-8') as gdump_file: gdump_contents = gdump_file.read() tpl_args['gdump_include'] = gdump_contents tpl_args['init_sections'] = "\n".join(self._options.init_sections) c_path = self._generate_tempfile(tmpdir, '.c') - with open(c_path, 'w') as f: + with open(c_path, 'w', encoding='utf-8') as f: f.write(_PROGRAM_TEMPLATE % tpl_args) # We need to reference our get_type and error_quark functions -- cgit v1.2.1