3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -417,6 +417,9 @@ def _parse(self, fp):
417
417
item = b_item .decode ().strip ()
418
418
if not item :
419
419
continue
420
+ # Skip over comment lines:
421
+ if item .startswith ('#-#-#-#-#' ) and item .endswith ('#-#-#-#-#' ):
422
+ continue
420
423
k = v = None
421
424
if ':' in item :
422
425
k , v = item .split (':' , 1 )
Original file line number Diff line number Diff line change @@ -684,6 +684,19 @@ def test_plural_form_error_issue17898(self):
684
684
# If this runs cleanly, the bug is fixed.
685
685
t = gettext .GNUTranslations (fp )
686
686
687
+ def test_ignore_comments_in_headers_issue36239 (self ):
688
+ """Checks that comments like:
689
+
690
+ #-#-#-#-# messages.po (EdX Studio) #-#-#-#-#
691
+
692
+ are ignored.
693
+ """
694
+ with open (MOFILE , 'wb' ) as fp :
695
+ fp .write (base64 .decodebytes (GNU_MO_DATA_ISSUE_17898 ))
696
+ with open (MOFILE , 'rb' ) as fp :
697
+ t = gettext .GNUTranslations (fp )
698
+ self .assertEqual (t .info ()["plural-forms" ], "nplurals=2; plural=(n != 1);" )
699
+
687
700
688
701
class UnicodeTranslationsTest (GettextBaseTest ):
689
702
def setUp (self ):
Original file line number Diff line number Diff line change
1
+ Parsing .mo files now ignores comments starting and ending with #-#-#-#-#.
0 commit comments