Message 27759 - Python tracker (original) (raw)
gettext chokes on empty Plural-Forms ?
#> audit2allow
Traceback (most recent call last): File "/usr/bin/audit2allow", line 34, in ? gettext.install('policycoreutils') File "/usr/lib/python2.4/gettext.py", line 482, in install t = translation(domain, localedir, fallback=True, codeset=codeset) File "/usr/lib/python2.4/gettexTraceback (most recent call last): File "/usr/bin/audit2allow", line 34, in ? gettext.install('policycoreutils') File "/usr/lib/python2.4/gettext.py", line 482, in install t = translation(domain, localedir, fallback=True, codeset=codeset) File "/usr/lib/python2.4/gettext.py", line 467, in translation t = translations.setdefault(key, class(open(mofile, 'rb'))) File "/usr/lib/python2.4/gettext.py", line 177, in init self._parse(fp) File "/usr/lib/python2.4/gettext.py", line 302, in _parse print v[1] IndexError: list index out of range t.py", line 467, in translation t = translations.setdefault(key, class(open(mofile, 'rb'))) File "/usr/lib/python2.4/gettext.py", line 177, in init self._parse(fp) File "/usr/lib/python2.4/gettext.py", line 302, in _parse print v[1] IndexError: list index out of range
#> msgunfmt /usr/share/locale/fr/LC_MESSAGES/policycoreutils.mo | grep -i plural "Plural-Forms: \n"
Bellow is a patch that fixes this for me.
--- /usr/lib/python2.4/gettext.py.orig 2007-02-13 13:25:54.000000000 +0100 +++ /usr/lib/python2.4/gettext.py 2007-02-13 12:36:29.000000000 +0100 @@ -298,8 +298,9 @@ self._charset = v.split('charset=')[1] elif k == 'plural-forms': v = v.split(';')
plural = v[1].split('plural=')[1]
self.plural = c2py(plural)
if len(v) > 1:
plural = v[1].split('plural=')[1]
self.plural = c2py(plural) # Note: we unconditionally convert both msgids and msgstrs to # Unicode using the character encoding specified in the charset # parameter of the Content-Type header. The gettext documentation