mirror of https://github.com/django/django.git
Fixed #34407 -- Reported filename when decoding fails in collectstatic's post_process.
This commit is contained in:
parent
4db33e96d1
commit
03bc92af97
|
@ -353,7 +353,10 @@ class HashedFilesMixin:
|
|||
# ..to apply each replacement pattern to the content
|
||||
if name in adjustable_paths:
|
||||
old_hashed_name = hashed_name
|
||||
content = original_file.read().decode("utf-8")
|
||||
try:
|
||||
content = original_file.read().decode("utf-8")
|
||||
except UnicodeDecodeError as exc:
|
||||
yield name, None, exc, False
|
||||
for extension, patterns in self._patterns.items():
|
||||
if matches_patterns(path, (extension,)):
|
||||
for pattern, template in patterns:
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
/* éviter écrasement */
|
||||
.test { margin: 1 rem; }
|
|
@ -368,6 +368,18 @@ class TestHashedFiles:
|
|||
self.assertEqual("Post-processing 'faulty.css' failed!\n\n", err.getvalue())
|
||||
self.assertPostCondition()
|
||||
|
||||
@override_settings(
|
||||
STATICFILES_DIRS=[os.path.join(TEST_ROOT, "project", "nonutf8")],
|
||||
STATICFILES_FINDERS=["django.contrib.staticfiles.finders.FileSystemFinder"],
|
||||
)
|
||||
def test_post_processing_nonutf8(self):
|
||||
finders.get_finder.cache_clear()
|
||||
err = StringIO()
|
||||
with self.assertRaises(UnicodeDecodeError):
|
||||
call_command("collectstatic", interactive=False, verbosity=0, stderr=err)
|
||||
self.assertEqual("Post-processing 'nonutf8.css' failed!\n\n", err.getvalue())
|
||||
self.assertPostCondition()
|
||||
|
||||
|
||||
@override_settings(
|
||||
STORAGES={
|
||||
|
|
Loading…
Reference in New Issue