diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2014-04-28 20:41:01 -0700 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-09-29 23:16:32 -0400 |
commit | 4ab4f3b0467616904ad5c114ea55325610d55087 (patch) | |
tree | a218fc7f95a1baef6cd22cfefdc2d6b60ee66106 /giscanner | |
parent | 0767a754f63423a4fb5d2cf279198dbc72e31543 (diff) | |
download | gobject-introspection-4ab4f3b0467616904ad5c114ea55325610d55087.tar.gz |
giscanner: Encode sha1 input for Python 3 compatibility
https://bugzilla.gnome.org/show_bug.cgi?id=679438
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/cachestore.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/giscanner/cachestore.py b/giscanner/cachestore.py index 20a6b606..007d992b 100644 --- a/giscanner/cachestore.py +++ b/giscanner/cachestore.py @@ -50,7 +50,8 @@ def _get_versionhash(): sources.append(sys.argv[0]) # Using mtimes is a bit (5x) faster than hashing the file contents mtimes = (str(os.stat(source).st_mtime) for source in sources) - return hashlib.sha1(''.join(mtimes)).hexdigest() + # ASCII encoding is sufficient since we are only dealing with numbers. + return hashlib.sha1(''.join(mtimes).encode('ascii')).hexdigest() class CacheStore(object): @@ -108,7 +109,9 @@ class CacheStore(object): # the cache all together. if self._directory is None: return - hexdigest = hashlib.sha1(filename).hexdigest() + # Assume UTF-8 encoding for the filenames. This doesn't matter so much + # as long as the results of this method always produce the same hash. + hexdigest = hashlib.sha1(filename.encode('utf-8')).hexdigest() return os.path.join(self._directory, hexdigest) def _cache_is_valid(self, store_filename, filename): |