Message188318
The gettext.py parser used by django (lib/python2.7/gettext.py),
GNUTranslations._parse(), around line 313 does not use clean values for k,v on each
iteration ("for item in tmsg.splitlines():")
To reproduce the problem (see traceback, below), try parsing a .PO file containing two headers like this, with a comment header immediately following a plurals header. This example was created by calling msgcat to combine several .po files into a single .po file. Msgcat inserted the comment line.
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"#-#-#-#-# messages.po (EdX Studio) #-#-#-#-#\n"
Parsing the first header binds the inner loop variables:
k= plural-forms v= ['nplurals=2', ' plural=(n != 1)', '']
Parsing the second header leaves k,v untouched, which then causes an improper
attempt to parse (since it's a comment, no further parsing of k,v should occur)
v = v.split(';')
Bug workaround: I use polib to read and immediately save the file. This reorders the metadata to avoid presenting the parser with something that will break it.
Recommended bug fix: on each iteration over tmsg.splitlines, reset the values of k,v = (None, None)
--------------------
Traceback:
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
89. response = middleware_method(request)
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/middleware/locale.py" in process_request
24. translation.activate(language)
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/utils/translation/__init__.py" in activate
105. return _trans.activate(language)
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in activate
201. _active.value = translation(language)
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in translation
191. current_translation = _fetch(language, fallback=default_translation)
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in _fetch
180. res = _merge(localepath)
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in _merge
156. t = _translation(path)
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in _translation
138. t = gettext_module.translation('django', path, [loc], DjangoTranslation)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py" in translation
480. t = _translations.setdefault(key, class_(fp))
File "/Users/sstrassmann/src/mitx_all/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in __init__
76. gettext_module.GNUTranslations.__init__(self, *args, **kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py" in __init__
180. self._parse(fp)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py" in _parse
315. v = v.split(';')
Exception Type: AttributeError at /
Exception Value: 'list' object has no attribute 'split' |
|
Date |
User |
Action |
Args |
2013-05-03 18:19:46 | straz | set | recipients:
+ straz |
2013-05-03 18:19:46 | straz | set | messageid: <1367605186.32.0.57972582146.issue17898@psf.upfronthosting.co.za> |
2013-05-03 18:19:46 | straz | link | issue17898 messages |
2013-05-03 18:19:45 | straz | create | |
|