diff --git a/assetman/compile.py b/assetman/compile.py index eb77b4d..03afa2a 100755 --- a/assetman/compile.py +++ b/assetman/compile.py @@ -204,9 +204,9 @@ def version_dependency(path, manifest): if manifest.assets[path]['version']: return manifest.assets[path]['version'] h = hashlib.md5() - h.update(get_file_hash(make_absolute_static_path(manifest.settings['static_dir'], path))) + h.update(get_file_hash(make_absolute_static_path(manifest.settings['static_dir'], path)).encode()) for dep_path in manifest.assets[path]['deps']: - h.update(version_dependency(dep_path, manifest)) + h.update(version_dependency(dep_path, manifest).encode()) version = h.hexdigest() _, ext = os.path.splitext(path) manifest.assets[path]['version'] = version diff --git a/assetman/compilers.py b/assetman/compilers.py index 3bb618e..240ca73 100644 --- a/assetman/compilers.py +++ b/assetman/compilers.py @@ -109,7 +109,7 @@ def get_current_content_hash(self, manifest): for path in self.get_paths(): relative_path = make_relative_static_path(self.settings['static_dir'], path) assert relative_path in manifest.assets, relative_path - h.update(manifest.assets[relative_path]['version']) + h.update(manifest.assets[relative_path]['version'].encode()) return h.hexdigest() def get_paths(self): diff --git a/assetman/managers.py b/assetman/managers.py index 53943ba..c9f8bc1 100644 --- a/assetman/managers.py +++ b/assetman/managers.py @@ -71,7 +71,7 @@ def get_hash(self): """Gets the md5 hash for the URLs in this block of assets, which will be used to refer to the compiled assets in production. """ - return hashlib.md5('\n'.join(self.rel_urls)).hexdigest() + return hashlib.md5('\n'.join(self.rel_urls).encode()).hexdigest() def get_ext(self): """Returns the file extension (without leading period) to use for the diff --git a/assetman/tools.py b/assetman/tools.py index 9dca3a7..3113266 100644 --- a/assetman/tools.py +++ b/assetman/tools.py @@ -21,9 +21,17 @@ def _crc(key): def _utf8(s): """encode a unicode string as utf-8""" if isinstance(s, str): - return s.encode("utf-8") + return s.encode("utf-8").decode() + if isinstance(s, bytes): + return s.decode("utf-8") assert isinstance(s, str), "_utf8 expected a str, not %r" % type(s) return s +#def _utf8(s): +# """encode a unicode string as utf-8""" +# if isinstance(s, str): +# return s.encode("utf-8") +# assert isinstance(s, str), "_utf8 expected a str, not %r" % type(s) +# return s def iter_template_paths(template_dirs, template_ext): """Walks each directory in the given list of template directories,