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:
Miss Islington (bot) 2019-08-29 23:23:17 -07:00 committed by Raymond Hettinger
parent c19d6bca55
commit 27f418640c
4 changed files with 24 additions and 8 deletions

View file

@ -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