Commits

David Jean Louis  committed 647b634

Fixed issue #26 IOError when parsing empty comments (thanks Türker Sezer) + added test

  • Participants
  • Parent commits e9c9340

Comments (0)

Files changed (3)

                 # we are on a msgstr plural
                 self.process('MX', i)
 
-            elif tokens[0] == '#,' and nb_tokens > 1:
+            elif tokens[0] == '#,' and nb_tokens >= 1:
                 # we are on a flags line
                 self.process('FL', i)
 
                 # we are on a translator comment line
                 self.process('TC', i)
 
-            elif tokens[0] == '#.' and nb_tokens > 1:
+            elif tokens[0] == '#.' and nb_tokens >= 1:
                 # we are on a generated comment line
                 self.process('GC', i)
 

File tests/test_weird_occurrences.po

 "X-Etoys-Domain: etoys\n"
 "X-Etoys-SystemVersion: etoys3.0 of 24 February 2008 update 2029\n"
 
+#. Test for empty comment lines
+#. 
+#,
+#: main.c:117
+msgid "Override the default prgname"
+msgstr "Override the default prgname"''
+
 #: Balloon-Fills,BitmapFillStyle>>addFillStyleMenuItems:hand:from:
 msgid "choose new graphic"
 msgstr "escolher novo gráfico"

File tests/tests.py

         po = polib.pofile('tests/test_iso-8859-15.po', encoding='iso-8859-15')
         self.assertTrue(po.encoding == 'iso-8859-15')
 
+    def test_obsolete_entries(self):
+        """
+        Test that weird occurrences are correctly parsed.
+        """
+        po = polib.pofile('tests/test_weird_occurrences.po')
+        self.assertEqual(len(po), 46)
+
     def test_detect_encoding1(self):
         """
         Test that given enconding is returned when file has no encoding defined.