summaryrefslogtreecommitdiff
path: root/giscanner/cachestore.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/cachestore.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/cachestore.py')
-rw-r--r--giscanner/cachestore.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/giscanner/cachestore.py b/giscanner/cachestore.py
index baaaf1ed..e3b76058 100644
--- a/giscanner/cachestore.py
+++ b/giscanner/cachestore.py
@@ -65,7 +65,7 @@ class CacheStore(object):
current_hash = _get_versionhash()
version = os.path.join(self._directory, _CACHE_VERSION_FILENAME)
try:
- with open(version, 'r') as version_file:
+ with open(version, 'r', encoding='utf-8') as version_file:
cache_hash = version_file.read()
except (IOError, OSError) as e:
# File does not exist
@@ -81,7 +81,7 @@ class CacheStore(object):
tmp_fd, tmp_filename = tempfile.mkstemp(prefix='g-ir-scanner-cache-version-')
try:
- with os.fdopen(tmp_fd, 'w') as tmp_file:
+ with os.fdopen(tmp_fd, 'w', encoding='utf-8') as tmp_file:
tmp_file.write(current_hash)
# On Unix, this would just be os.rename() but Windows