Fixed #32144 -- Made makemessages remove temporary files when locale path doesn't exist.

This commit is contained in:
Carlton Gibson 2021-06-30 14:09:20 +02:00 committed by Carlton Gibson
parent 8feb2a49fa
commit dfa7781033
3 changed files with 8 additions and 0 deletions

View File

@ -581,6 +581,8 @@ class Command(BaseCommand):
if msgs:
if locale_dir is NO_LOCALE_DIR:
for build_file in build_files:
build_file.cleanup()
file_path = os.path.normpath(build_files[0].path)
raise CommandError(
"Unable to find a locale path to store translations for "

View File

@ -0,0 +1,4 @@
A non-Python file will be classed as translatable.
The temporary file created from this should be removed from the file system if
an error is raised.

View File

@ -765,6 +765,8 @@ class CustomLayoutExtractionTests(ExtractorTests):
)
with self.assertRaisesMessage(management.CommandError, msg):
management.call_command('makemessages', locale=[LOCALE], verbosity=0)
# Working files are cleaned up on an error.
self.assertFalse(os.path.exists('./app_no_locale/test.html.py'))
def test_project_locale_paths(self):
self._test_project_locale_paths(os.path.join(self.test_dir, 'project_locale'))