carlxaeron / django-rosetta

Automatically exported from code.google.com/p/django-rosetta
MIT License
0 stars 0 forks source link

django crashes when trying to load .mo file if the "Last-Translator" string from the original .po has a non-english character #37

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Set first_name or last_name for superuser or another user in group 
'translators' with a special character like 'é'
2. Edit with that user a translation file
3. Save it and try to load any URL of the project

What version of the product are you using? On what operating system?
Using svn version.

This is the output:
--------------

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 228, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 201, in __call__
    response = self.get_response(request)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 67, in get_response
    response = middleware_method(request)

  File "/usr/lib/python2.4/site-packages/django/middleware/locale.py", line 17, in process_request
    translation.activate(language)

  File "/usr/lib/python2.4/site-packages/django/utils/translation/__init__.py", line 73, in activate
    return real_activate(language)

  File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 209, in activate
    _active[currentThread()] = translation(language)

  File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 199, in translation
    current_translation = _fetch(language, fallback=default_translation)

  File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 176, in _fetch
    res = _merge(projectpath)

  File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 163, in _merge
    t = _translation(path)

  File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 145, in _translation
    t = gettext_module.translation('django', path, [loc], klass)

  File "/usr/lib/python2.4/gettext.py", line 489, in translation
    t = _translations.setdefault(key, class_(open(mofile, 'rb')))

  File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 62, in __init__
    gettext_module.GNUTranslations.__init__(self, *args, **kw)

  File "/usr/lib/python2.4/gettext.py", line 177, in __init__
    self._parse(fp)

  File "/usr/lib/python2.4/gettext.py", line 324, in _parse
    tmsg = unicode(tmsg, self._charset)

  File "/usr/lib/python2.4/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 163-165: 
invalid data

Original issue reported on code.google.com by antonio....@gmail.com on 30 Nov 2008 at 8:34

GoogleCodeExporter commented 8 years ago
This works for me. Could you please attach a zipfile containing both the po and
associated mo file triggering this bug?

Oh and this looks alot like Issue #15

Original comment by mbonetti on 3 Dec 2008 at 10:52

GoogleCodeExporter commented 8 years ago
When using "Mele" as user.last_name everything works ok, but using "Melé" as 
user.last_name makes getting Last-Translator name from the .mo file somehow 
unable to be decoded. When I save the .po file after changing 
that 'é' and generating a new .mo everything works ok again. I attach files 
not working (django.po & django.mo) 
and files working ok after change (django_works.po & django_works.mo).

Original comment by antonio....@gmail.com on 3 Dec 2008 at 11:24

Attachments:

GoogleCodeExporter commented 8 years ago
Sorry for the delay. This is an encoding issue, your "broken" po file isn't 
utf8 in
the first place, even though it should be.

(15:54)-(~):: file ~/Downloads/catalogs/*.po
/Users/marco/Downloads/catalogs/django.po:       ISO-8859 English text
/Users/marco/Downloads/catalogs/django_works.po: UTF-8 Unicode English text

Original comment by mbonetti on 8 Jan 2009 at 2:57

GoogleCodeExporter commented 8 years ago
This should be fixed as of r81.

Original comment by mbonetti on 12 Nov 2009 at 2:24