@@ -134,6 +134,12 @@ def tearDown(self):
134134 del self .env
135135 support .rmtree (os .path .split (LOCALEDIR )[0 ])
136136
137+ GNU_MO_DATA_ISSUE_17898 = b'''\
138+ 3hIElQAAAAABAAAAHAAAACQAAAAAAAAAAAAAAAAAAAAsAAAAggAAAC0AAAAAUGx1cmFsLUZvcm1z
139+ OiBucGx1cmFscz0yOyBwbHVyYWw9KG4gIT0gMSk7CiMtIy0jLSMtIyAgbWVzc2FnZXMucG8gKEVk
140+ WCBTdHVkaW8pICAjLSMtIy0jLSMKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PVVU
141+ Ri04CgA=
142+ '''
137143
138144class GettextTestCase1 (GettextBaseTest ):
139145 def setUp (self ):
@@ -360,6 +366,14 @@ def test_security(self):
360366 # Test for a dangerous expression
361367 raises (ValueError , gettext .c2py , "os.chmod('/etc/passwd',0777)" )
362368
369+ class GNUTranslationParsingTest (GettextBaseTest ):
370+ def test_plural_form_error_issue17898 (self ):
371+ with open (MOFILE , 'wb' ) as fp :
372+ fp .write (base64 .decodebytes (GNU_MO_DATA_ISSUE_17898 ))
373+ with open (MOFILE , 'rb' ) as fp :
374+ # If this runs cleanly, the bug is fixed.
375+ t = gettext .GNUTranslations (fp )
376+
363377
364378class UnicodeTranslationsTest (GettextBaseTest ):
365379 def setUp (self ):
@@ -535,3 +549,16 @@ def test_main():
535549"Content-Transfer-Encoding: quoted-printable\n "
536550"Generated-By: pygettext.py 1.3\n "
537551'''
552+
553+ #
554+ # messages.po, used for bug 17898
555+ #
556+
557+ '''
558+ # test file for http://bugs.python.org/issue17898
559+ msgid ""
560+ msgstr ""
561+ "Plural-Forms: nplurals=2; plural=(n != 1);\n "
562+ "#-#-#-#-# messages.po (EdX Studio) #-#-#-#-#\n "
563+ "Content-Type: text/plain; charset=UTF-8\n "
564+ '''
0 commit comments