[Python-checkins] cpython (merge 3.4 -> default): Merge from 3.4

andrew.kuchling python-checkins at python.org
Tue Apr 14 16:36:42 CEST 2015


https://hg.python.org/cpython/rev/3bbe18aaea8c
changeset:   95639:3bbe18aaea8c
parent:      95634:5f04daa34a55
parent:      95638:6cdfab400707
user:        Andrew Kuchling <amk at amk.ca>
date:        Tue Apr 14 10:35:43 2015 -0400
summary:
  Merge from 3.4

files:
  Lib/gettext.py           |   3 ++-
  Lib/test/test_gettext.py |  27 +++++++++++++++++++++++++++
  Misc/NEWS                |   4 ++--
  3 files changed, 31 insertions(+), 3 deletions(-)


diff --git a/Lib/gettext.py b/Lib/gettext.py
--- a/Lib/gettext.py
+++ b/Lib/gettext.py
@@ -275,11 +275,12 @@
             # See if we're looking at GNU .mo conventions for metadata
             if mlen == 0:
                 # Catalog description
-                lastk = k = None
+                lastk = None
                 for b_item in tmsg.split('\n'.encode("ascii")):
                     item = b_item.decode().strip()
                     if not item:
                         continue
+                    k = v = None
                     if ':' in item:
                         k, v = item.split(':', 1)
                         k = k.strip().lower()
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -134,6 +134,12 @@
         del self.env
         support.rmtree(os.path.split(LOCALEDIR)[0])
 
+GNU_MO_DATA_ISSUE_17898 = b'''\
+3hIElQAAAAABAAAAHAAAACQAAAAAAAAAAAAAAAAAAAAsAAAAggAAAC0AAAAAUGx1cmFsLUZvcm1z
+OiBucGx1cmFscz0yOyBwbHVyYWw9KG4gIT0gMSk7CiMtIy0jLSMtIyAgbWVzc2FnZXMucG8gKEVk
+WCBTdHVkaW8pICAjLSMtIy0jLSMKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PVVU
+Ri04CgA=
+'''
 
 class GettextTestCase1(GettextBaseTest):
     def setUp(self):
@@ -360,6 +366,14 @@
         # Test for a dangerous expression
         raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)")
 
+class GNUTranslationParsingTest(GettextBaseTest):
+    def test_plural_form_error_issue17898(self):
+        with open(MOFILE, 'wb') as fp:
+            fp.write(base64.decodebytes(GNU_MO_DATA_ISSUE_17898))
+        with open(MOFILE, 'rb') as fp:
+            # If this runs cleanly, the bug is fixed.
+            t = gettext.GNUTranslations(fp)
+
 
 class UnicodeTranslationsTest(GettextBaseTest):
     def setUp(self):
@@ -535,3 +549,16 @@
 "Content-Transfer-Encoding: quoted-printable\n"
 "Generated-By: pygettext.py 1.3\n"
 '''
+
+#
+# messages.po, used for bug 17898
+#
+
+'''
+# test file for http://bugs.python.org/issue17898
+msgid ""
+msgstr ""
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"#-#-#-#-#  messages.po (EdX Studio)  #-#-#-#-#\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+'''
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -47,8 +47,8 @@
 - Issue #21859: Added Python implementation of io.FileIO.
 
 - Issue #23865: close() methods in multiple modules now are idempotent and more
-  robust at shutdown. If needs to release multiple resources, they are released
-  even if errors are occured.
+  robust at shutdown. If they need to release multiple resources, all are
+  released even if errors occur.
 
 - Issue #23400: Raise same exception on both Python 2 and 3 if sem_open is not
   available.  Patch by Davin Potts.

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list