This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Michael.Müller
Recipients Michael.Müller
Date 2013-12-06.11:20:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1386328833.52.0.797354581277.issue19907@psf.upfronthosting.co.za>
In-reply-to
Content
When having non ascii chars in the header of an translation file (xxx.po) the following error will be raised:

  File "D:\Python33\lib\gettext.py", line 410, in translation
    t = _translations.setdefault(key, class_(fp))
  File "D:\Python33\lib\gettext.py", line 160, in __init__
    self._parse(fp)
  File "D:\Python33\lib\gettext.py", line 265, in _parse
    item = b_item.decode().strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 51: invalid continuation byte

translation file head:

"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-12-06 11:47\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE+Mitteleuropäische Zeit\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: utf-8\n"
"Generated-By: pygettext.py 1.5\n"

The problem here exists with the PO-Revision-Date which is followed by the timezone offset in current language (here "Mitteleuropäische Zeit") which is automatically added by pygettext.py.
When removing it the file will work without any problems.

Current pygettext.py code part:
[Line 444] ...
    def write(self, fp):
        options = self.__options
        timestamp = time.strftime('%Y-%m-%d %H:%M+%Z')
        # The time stamp in the header doesn't have the same format as that
        # generated by xgettext...
        print(pot_header % {'time': timestamp, 'version': __version__}, file=fp)
...

To avoid this it would be better to use gmtime and not to append the timezone:

...
    def write(self, fp):
        options = self.__options
        timestamp = time.strftime('%Y-%m-%d %H:%M', time.gmtime())
...
History
Date User Action Args
2013-12-06 11:20:33Michael.Müllersetrecipients: + Michael.Müller
2013-12-06 11:20:33Michael.Müllersetmessageid: <1386328833.52.0.797354581277.issue19907@psf.upfronthosting.co.za>
2013-12-06 11:20:33Michael.Müllerlinkissue19907 messages
2013-12-06 11:20:32Michael.Müllercreate