Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29246 closed Bug (needsinfo)

compilemessages management-command fails with UnicodeDecodeError

Reported by: Tarun Gaba Owned by: Liuyang Qin
Component: Internationalization Version: 1.11
Severity: Normal Keywords: compilemessages UnicodeDecodeError
Cc: Daniel Browne Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


When running compilemessages command on a django project which contains Unicode characters in filenames (for example in static files), it fails with a UnicodeError:

Traceback (most recent call last):
  File "", line 62, in <module>
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/", line 364, in execute_from_command_line
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/", line 356, in execute
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/", line 70, in handle
    for dirpath, dirnames, filenames in os.walk('.', topdown=True):
  File "/usr/lib/python2.7/", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/", line 284, in walk
    if isdir(join(top, name)):
  File "/usr/lib/python2.7/", line 80, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 23: ordinal not in range(128)

The 'walk' functionality in compilemessages was introduced in django 1.9: (

Change History (6)

comment:1 by Tim Graham, 6 years ago

Component: UncategorizedInternationalization
Resolution: invalid
Status: newclosed

Django 1.9 is no longer supported. Please reopen if you can reproduce with Django's master branch, which supports only Python 3.

comment:2 by Daniel Browne, 6 years ago

Cc: Daniel Browne added
Resolution: invalid
Status: closednew
Version: 1.91.11

I can reproduce this issue on Django 1.11 which is still supported. Can the '.' passed to os.walk not become b'.' in order to bypass the unicode_literals import? I think this would solve the problem.

comment:3 by Tim Graham, 6 years ago

Per our supported versions policy, 1.11 is only receiving data loss and security fixes. Can the issue be reproduce on Django's master branch (which supports Python 3 only).

comment:4 by Liuyang Qin, 6 years ago

Owner: changed from nobody to Liuyang Qin
Status: newassigned

comment:5 by Tim Graham, 6 years ago

Resolution: needsinfo
Status: assignedclosed

comment:6 by Sebastien Renard, 6 years ago

Got the same bug on django 1.11. One simple way to workaround this is to cd to your locale/ directory before calling compilemessages. Btw that also speed up things, avoiding to search locale folders everywhere.

Note: See TracTickets for help on using tickets.
Back to Top