﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25677	compilemessages throws an exception and does not report msgformat errors correctly	Gavin Wahl	Ramiro Morales	"I have a django.po with errors. When I run compilemessages, instead of getting a sensible error, I get a UnicodeDecodeError.

{{{
Traceback (most recent call last):
  File ""/usr/lib/python3.4/pdb.py"", line 1661, in main
    pdb._runscript(mainpyfile)
  File ""/usr/lib/python3.4/pdb.py"", line 1542, in _runscript
    self.run(statement)
  File ""/usr/lib/python3.4/bdb.py"", line 431, in run
    exec(cmd, globals, locals)
  File ""<string>"", line 1, in <module>
  File ""manage.py"", line 2, in <module>
    import os
  File ""django/core/management/__init__.py"", line 350, in execute_from_command_line
    utility.execute()
  File ""django/core/management/__init__.py"", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""django/core/management/base.py"", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File ""django/core/management/base.py"", line 399, in execute
    output = self.handle(*args, **options)
  File ""django/core/management/commands/compilemessages.py"", line 98, in handle
    self.compile_messages(locations)
  File ""django/core/management/commands/compilemessages.py"", line 122, in compile_messages
    output, errors, status = popen_wrapper(args)
  File ""django/core/management/utils.py"", line 27, in popen_wrapper
    output, errors = p.communicate()
  File ""/usr/lib/python3.4/subprocess.py"", line 962, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File ""/usr/lib/python3.4/subprocess.py"", line 1664, in _communicate
    self.stderr.encoding)
  File ""/usr/lib/python3.4/subprocess.py"", line 888, in _translate_newlines
    data = data.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 179: invalid continuation byte
}}}

I should get the error from msgformat:

{{{
$ msgfmt --check-format -o locale/es/LC_MESSAGES/django.mo locale/es/LC_MESSAGES/django.po
locale/es/LC_MESSAGES/django.po:112: 'msgstr' is not a valid Python brace format string, unlike 'msgid'. Reason: In the directive number 0, '�' cannot start a field name.
msgfmt: found 1 fatal error
}}}

The problem is that the output of msgformat is _not_ a utf-8 string. It's bytes. Any attempt to decode it into unicode is futile.

The exact output of msgformat is b""locale/es/LC_MESSAGES/django.po:112: 'msgstr' is not a valid Python brace format string, unlike 'msgid'. Reason: In the directive number 0, '\xc5' cannot start a field name.\nmsgfmt: found 1 fatal error\n"".
"	Bug	closed	Internationalization	dev	Normal	fixed	1.10 windows	Ramiro Morales	Accepted	0	0	0	0	0	0
