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
8b963c58
Commit
8b963c58
authored
Apr 13, 2015
by
Andrew Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#17898: reset k and v so that the loop doesn't use an old value
parent
770b08e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
Lib/gettext.py
Lib/gettext.py
+2
-1
Lib/test/test_gettext.py
Lib/test/test_gettext.py
+27
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/gettext.py
View file @
8b963c58
...
...
@@ -262,11 +262,12 @@ class GNUTranslations(NullTranslations):
# 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
()
...
...
Lib/test/test_gettext.py
View file @
8b963c58
...
...
@@ -79,6 +79,12 @@ class GettextBaseTest(unittest.TestCase):
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
):
...
...
@@ -290,6 +296,14 @@ class PluralFormsTestCase(GettextBaseTest):
# 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
):
...
...
@@ -465,3 +479,16 @@ msgstr ""
"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
"
'''
Misc/NEWS
View file @
8b963c58
...
...
@@ -29,6 +29,8 @@ Core and Builtins
Library
-------
- Issue #17898: Fix exception in gettext.py when parsing certain plural forms.
- Issue #22982: Improve BOM handling when seeking to multiple positions of
a writable text file.
...
...
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