mirror of
https://github.com/python/cpython.git
synced 2025-08-15 14:20:55 +00:00
bpo-37976: Prevent shadowing of TypeError in zip() (GH-15592) (GH-15608)
(cherry picked from commit 6a650aaf77
)
Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
This commit is contained in:
parent
c19d6bca55
commit
27f418640c
4 changed files with 24 additions and 8 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue