From 67870137b9e1f1384af7465b4eb978d0f4dab3b7 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 12 Aug 2014 22:27:38 +0200 Subject: [PATCH] [1.7.x] Fixed #22686 -- Prevented makemessages crash with unicode filename A more extensive fix has been reverted on the 1.7.x branch, so this minimal fix replaces it. --- django/core/management/commands/makemessages.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py index def3461201..11b36aebb2 100644 --- a/django/core/management/commands/makemessages.py +++ b/django/core/management/commands/makemessages.py @@ -12,7 +12,7 @@ from django.conf import settings from django.core.management.base import CommandError, NoArgsCommand from django.core.management.utils import (handle_extensions, find_command, popen_wrapper) -from django.utils.encoding import force_str +from django.utils.encoding import force_str, force_text from django.utils.functional import total_ordering from django.utils import six from django.utils.text import get_text_list @@ -132,11 +132,11 @@ class TranslatableFile(object): # Remove '.py' suffix if os.name == 'nt': # Preserve '.\' prefix on Windows to respect gettext behavior - old = '#: ' + work_file - new = '#: ' + orig_file + old = '#: ' + force_str(work_file) + new = '#: ' + force_str(orig_file) else: - old = '#: ' + work_file[2:] - new = '#: ' + orig_file[2:] + old = '#: ' + force_str(work_file[2:]) + new = '#: ' + force_str(orig_file[2:]) msgs = msgs.replace(old, new) write_pot_file(potfile, msgs) @@ -350,7 +350,7 @@ class Command(NoArgsCommand): dir_suffix = '%s*' % os.sep norm_patterns = [p[:-len(dir_suffix)] if p.endswith(dir_suffix) else p for p in self.ignore_patterns] all_files = [] - for dirpath, dirnames, filenames in os.walk(root, topdown=True, followlinks=self.symlinks): + for dirpath, dirnames, filenames in os.walk(force_text(root), topdown=True, followlinks=self.symlinks): for dirname in dirnames[:]: if is_ignored(os.path.normpath(os.path.join(dirpath, dirname)), norm_patterns): dirnames.remove(dirname)