summaryrefslogtreecommitdiff
path: root/giscanner/dumper.py
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2020-11-07 08:41:42 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2020-11-07 08:57:06 +0100
commit5f966b0b8d61e2abf003439b2f93a9bd19be798c (patch)
tree530128d2a9ee1a0b4cd3c9702d5de5862943aa1f /giscanner/dumper.py
parent19c67f77e23cf80da957bfa0b28c1b31d81339f0 (diff)
downloadgobject-introspection-5f966b0b8d61e2abf003439b2f93a9bd19be798c.tar.gz
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.
Diffstat (limited to 'giscanner/dumper.py')
-rw-r--r--giscanner/dumper.py4
1 files changed, 2 insertions, 2 deletions
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