mirror of
https://github.com/django/django.git
synced 2025-10-29 00:26:07 +00:00
Fixed #22315 -- str/bytes mismatch in staticfiles
Previously, `ManifestFilesMixin.read_manifest` failed in Python 3 because `json.loads` accepts `str` not `bytes`.
This commit is contained in:
@@ -292,7 +292,7 @@ class ManifestFilesMixin(HashedFilesMixin):
|
||||
def read_manifest(self):
|
||||
try:
|
||||
with self.open(self.manifest_name) as manifest:
|
||||
return manifest.read()
|
||||
return manifest.read().decode('utf-8')
|
||||
except IOError:
|
||||
return None
|
||||
|
||||
@@ -319,7 +319,8 @@ class ManifestFilesMixin(HashedFilesMixin):
|
||||
payload = {'paths': self.hashed_files, 'version': self.manifest_version}
|
||||
if self.exists(self.manifest_name):
|
||||
self.delete(self.manifest_name)
|
||||
self._save(self.manifest_name, ContentFile(json.dumps(payload)))
|
||||
contents = json.dumps(payload).encode('utf-8')
|
||||
self._save(self.manifest_name, ContentFile(contents))
|
||||
|
||||
|
||||
class _MappingCache(object):
|
||||
|
||||
Reference in New Issue
Block a user