1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed #26897 -- Fixed makemessages crash on Python 2 with non-ASCII file names

Thanks Tim Graham for the review.
This commit is contained in:
Claude Paroz 2016-07-14 18:24:40 +02:00
parent 8ef78b8165
commit 3e71f6544f
3 changed files with 8 additions and 1 deletions

View File

@ -549,7 +549,7 @@ class Command(BaseCommand):
input_files = [bf.work_path for bf in build_files]
with NamedTemporaryFile(mode='w+') as input_files_list:
input_files_list.write('\n'.join(input_files))
input_files_list.write(force_str('\n'.join(input_files), encoding=DEFAULT_LOCALE_ENCODING))
input_files_list.flush()
args.extend(['--files-from', input_files_list.name])
args.extend(self.xgettext_options)

View File

@ -12,3 +12,6 @@ Bugfixes
* Fixed missing ``varchar/text_pattern_ops`` index on ``CharField`` and
``TextField`` respectively when using ``AddField`` on PostgreSQL
(:ticket:`26889`).
* Fixed ``makemessages`` crash on Python 2 with non-ASCII file names
(:ticket:`26897`).

View File

@ -209,6 +209,10 @@ class BasicExtractorTests(ExtractorTests):
self.assertIn("UnicodeDecodeError: skipped file not_utf8.txt in .",
force_text(out.getvalue()))
def test_unicode_file_name(self):
open(os.path.join(self.test_dir, 'vidéo.txt'), 'a').close()
management.call_command('makemessages', locale=[LOCALE], verbosity=0)
def test_extraction_warning(self):
"""test xgettext warning about multiple bare interpolation placeholders"""
shutil.copyfile('./code.sample', './code_sample.py')