Bugs item #1448060, was opened at 2006-03-12 00:20 Message generated for change (Settings changed) made by dsegan You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1448060&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Danilo Segan (dsegan) Assigned to: Nobody/Anonymous (nobody) >Summary: gettext.py breaks on plural-forms header (PATCH) Initial Comment: See http://bugzilla.gnome.org/show_bug.cgi?id=334256 The problem is a PO file like the following: test.po: msgid "" msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "#-#-#-#-# plo.po (PACKAGE VERSION) #-#-#-#-#\n" (these kinds of entries are sometimes inserted by msgmerge, so they're somewhat common) Any Python program trying to access this breaks: $ python test.py Traceback (most recent call last): File "test.py", line 7, in ? gt = gettext.GNUTranslations(file) File "/usr/lib/python2.4/gettext.py", line 177, in __init__ self._parse(fp) File "/usr/lib/python2.4/gettext.py", line 300, in _parse v = v.split(';') AttributeError: 'list' object has no attribute 'split' test.py is simple: #!/usr/bin/env python import gettext file = open("test.mo", "rb") if file: gt = gettext.GNUTranslations(file) The problem is the corner-case: plural-forms precedes this kind of comment, so "v" is split (v=v.split(";")). In the next instance, lastk is "plural-forms", yet the entry doesn't contain ":", so it tries to set plural forms to v.split(";") again, which fails since v is already a list. The attached simple patch fixes this. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1448060&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com