diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2015-09-12 16:36:15 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <sweskman@gmail.com> | 2015-09-12 16:36:15 (GMT) |
commit | a8a930f86393cd037da4aab7906de0522fbce8dc (patch) | |
tree | bf70c29a34c53810adbf0ad874370f81412fe161 /Lib/test/test_itertools.py | |
parent | 233cdb3e9c3d55a90763e9d5791b9e36f0a17882 (diff) | |
parent | d7f65e5763fdf16afa0dc786bcc3e40024037aaf (diff) | |
download | cpython-a8a930f86393cd037da4aab7906de0522fbce8dc.zip cpython-a8a930f86393cd037da4aab7906de0522fbce8dc.tar.gz cpython-a8a930f86393cd037da4aab7906de0522fbce8dc.tar.bz2 |
Issue #25021: Merge 3.5 to default
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r-- | Lib/test/test_itertools.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 81e1711..9e55b2a 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1035,6 +1035,16 @@ class TestBasicOps(unittest.TestCase): for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, product(*args)) + def test_product_issue_25021(self): + # test that indices are properly clamped to the length of the tuples + p = product((1, 2),(3,)) + p.__setstate__((0, 0x1000)) # will access tuple element 1 if not clamped + self.assertEqual(next(p), (2, 3)) + # test that empty tuple in the list will result in an immediate StopIteration + p = product((1, 2), (), (3,)) + p.__setstate__((0, 0, 0x1000)) # will access tuple element 1 if not clamped + self.assertRaises(StopIteration, next, p) + def test_repeat(self): self.assertEqual(list(repeat(object='a', times=3)), ['a', 'a', 'a']) self.assertEqual(lzip(range(3),repeat('a')), |