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
6a650aaf
Commit
6a650aaf
authored
Aug 30, 2019
by
Sergey Fedoseev
Committed by
Raymond Hettinger
Aug 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-37976: Prevent shadowing of TypeError in zip() (GH-15592)
parent
496058f5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
8 deletions
+24
-8
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+12
-0
Lib/test/test_itertools.py
Lib/test/test_itertools.py
+12
-0
Modules/itertoolsmodule.c
Modules/itertoolsmodule.c
+0
-4
Python/bltinmodule.c
Python/bltinmodule.c
+0
-4
No files found.
Lib/test/test_builtin.py
View file @
6a650aaf
...
...
@@ -1477,6 +1477,18 @@ class BuiltinTest(unittest.TestCase):
z1
=
zip
(
a
,
b
)
self
.
check_iter_pickle
(
z1
,
t
,
proto
)
def
test_zip_bad_iterable
(
self
):
exception
=
TypeError
()
class
BadIterable
:
def
__iter__
(
self
):
raise
exception
with
self
.
assertRaises
(
TypeError
)
as
cm
:
zip
(
BadIterable
())
self
.
assertIs
(
cm
.
exception
,
exception
)
def
test_format
(
self
):
# Test the basic machinery of the format() builtin. Don't test
# the specifics of the various formatters
...
...
Lib/test/test_itertools.py
View file @
6a650aaf
...
...
@@ -971,6 +971,18 @@ class TestBasicOps(unittest.TestCase):
self
.
pickletest
(
proto
,
zip_longest
(
"abc"
,
"defgh"
,
fillvalue
=
1
))
self
.
pickletest
(
proto
,
zip_longest
(
""
,
"defgh"
))
def
test_zip_longest_bad_iterable
(
self
):
exception
=
TypeError
()
class
BadIterable
:
def
__iter__
(
self
):
raise
exception
with
self
.
assertRaises
(
TypeError
)
as
cm
:
zip_longest
(
BadIterable
())
self
.
assertIs
(
cm
.
exception
,
exception
)
def
test_bug_7244
(
self
):
class
Repeater
:
...
...
Modules/itertoolsmodule.c
View file @
6a650aaf
...
...
@@ -4442,10 +4442,6 @@ zip_longest_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject
*
item
=
PyTuple_GET_ITEM
(
args
,
i
);
PyObject
*
it
=
PyObject_GetIter
(
item
);
if
(
it
==
NULL
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_TypeError
))
PyErr_Format
(
PyExc_TypeError
,
"zip_longest argument #%zd must support iteration"
,
i
+
1
);
Py_DECREF
(
ittuple
);
return
NULL
;
}
...
...
Python/bltinmodule.c
View file @
6a650aaf
...
...
@@ -2548,10 +2548,6 @@ zip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject
*
item
=
PyTuple_GET_ITEM
(
args
,
i
);
PyObject
*
it
=
PyObject_GetIter
(
item
);
if
(
it
==
NULL
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_TypeError
))
PyErr_Format
(
PyExc_TypeError
,
"zip argument #%zd must support iteration"
,
i
+
1
);
Py_DECREF
(
ittuple
);
return
NULL
;
}
...
...
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