Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
afd1e6d2
Commit
afd1e6d2
authored
May 09, 2019
by
Julien Palard
Committed by
GitHub
May 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36239: Skip comments in gettext infos (GH-12255)
parent
88db8bd0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
Lib/gettext.py
Lib/gettext.py
+3
-0
Lib/test/test_gettext.py
Lib/test/test_gettext.py
+13
-0
Misc/NEWS.d/next/Library/2019-03-09-23-51-27.bpo-36239.BHJ3Ln.rst
...S.d/next/Library/2019-03-09-23-51-27.bpo-36239.BHJ3Ln.rst
+1
-0
No files found.
Lib/gettext.py
View file @
afd1e6d2
...
...
@@ -417,6 +417,9 @@ class GNUTranslations(NullTranslations):
item
=
b_item
.
decode
().
strip
()
if
not
item
:
continue
# Skip over comment lines:
if
item
.
startswith
(
'#-#-#-#-#'
)
and
item
.
endswith
(
'#-#-#-#-#'
):
continue
k
=
v
=
None
if
':'
in
item
:
k
,
v
=
item
.
split
(
':'
,
1
)
...
...
Lib/test/test_gettext.py
View file @
afd1e6d2
...
...
@@ -684,6 +684,19 @@ class GNUTranslationParsingTest(GettextBaseTest):
# If this runs cleanly, the bug is fixed.
t
=
gettext
.
GNUTranslations
(
fp
)
def
test_ignore_comments_in_headers_issue36239
(
self
):
"""Checks that comments like:
#-#-#-#-# messages.po (EdX Studio) #-#-#-#-#
are ignored.
"""
with
open
(
MOFILE
,
'wb'
)
as
fp
:
fp
.
write
(
base64
.
decodebytes
(
GNU_MO_DATA_ISSUE_17898
))
with
open
(
MOFILE
,
'rb'
)
as
fp
:
t
=
gettext
.
GNUTranslations
(
fp
)
self
.
assertEqual
(
t
.
info
()[
"plural-forms"
],
"nplurals=2; plural=(n != 1);"
)
class
UnicodeTranslationsTest
(
GettextBaseTest
):
def
setUp
(
self
):
...
...
Misc/NEWS.d/next/Library/2019-03-09-23-51-27.bpo-36239.BHJ3Ln.rst
0 → 100644
View file @
afd1e6d2
Parsing .mo files now ignores comments starting and ending with #-#-#-#-#.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment