summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-08-12 22:27:38 +0200
committerClaude Paroz <claude@2xlibre.net>2014-08-12 22:55:35 +0200
commit67870137b9e1f1384af7465b4eb978d0f4dab3b7 (patch)
tree27730ca1cd64710a0bb87c3323b98df58846d294
parente705d8c4b49d5c5ee747075f12709011f55b7a8a (diff)
[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.
-rw-r--r--django/core/management/commands/makemessages.py12
1 files 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)