Opened 17 years ago

Closed 17 years ago

#6861 closed (fixed)

I18N fails on start. struct.error: unpack str size does not match format

Reported by: david.rubert@… Owned by: nobody
Component: Internationalization Version: dev
Severity: Keywords: i18n gettext error
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Revision 7352 of repository applied some changes that prevent a i18n enabled project to start.

When I try to start a i18n enabled project, I get this:

Traceback (most recent call last):
  File "manage.py", line 16, in ?
    execute_manager(settings)
  File "../shared/django/core/management/__init__.py", line 272, in execute_manager
    utility.execute()
  File "../shared/django/core/management/__init__.py", line 219, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "../shared/django/core/management/base.py", line 72, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "../shared/django/core/management/base.py", line 81, in execute
    translation.activate('en-us')
  File "../shared/django/utils/translation/__init__.py", line 73, in activate
    return real_activate(language)
  File "../shared/django/utils/translation/__init__.py", line 43, in delayed_loader
    return g['real_%s' % caller](*args, **kwargs)
  File "../shared/django/utils/translation/trans_real.py", line 211, in activate
    _active[currentThread()] = translation(language)
  File "../shared/django/utils/translation/trans_real.py", line 200, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "../shared/django/utils/translation/trans_real.py", line 190, in _fetch
    res = _merge(apppath)
  File "../shared/django/utils/translation/trans_real.py", line 165, in _merge
    t = _translation(path)
  File "../shared/django/utils/translation/trans_real.py", line 156, in _translation
    t = gettext_module.translation('django', path, [loc], klass)
  File "/usr/lib/python2.4/gettext.py", line 465, in translation
    t = _translations.setdefault(key, class_(open(mofile, 'rb')))
  File "../shared/django/utils/translation/trans_real.py", line 73, 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 260, in _parse
    magic = unpack('<I', buf[:4])[0]
struct.error: unpack str size does not match format

Change History (3)

comment:1 by James Bennett, 17 years ago

[7352] could not have done this; please try an earlier revision to locate the error.

comment:2 by Malcolm Tredinnick, 17 years ago

This error message suggests that your .mo file is somehow corrupt. Try regenerating it from the PO file again.

The line of code that is raising the error isn't Django dependent at all. It's trying to parse the entire MO file to prepare that translation for use and it cannot parse that file.

comment:3 by david.rubert@…, 17 years ago

Resolution: fixed
Status: newclosed

You're totally right. It was a weird corrupted .mo file. Once regenerated, everything works again.

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