summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2015-09-12 15:30:23 (GMT)
committerKristján Valur Jónsson <sweskman@gmail.com>2015-09-12 15:30:23 (GMT)
commit95c3e6cb2243acc0a102d9fa59efece1427a3936 (patch)
treeec383c38241ed66bbb1bc17dbd1b68bcb3306a79 /Lib
parent0424eaf7533b0f386f6038dbb99f89e30fbbff76 (diff)
parent102764a1f6927955b9a907005ffd07216ebe1d96 (diff)
downloadcpython-95c3e6cb2243acc0a102d9fa59efece1427a3936.zip
cpython-95c3e6cb2243acc0a102d9fa59efece1427a3936.tar.gz
cpython-95c3e6cb2243acc0a102d9fa59efece1427a3936.tar.bz2
Issue #25021: Merge from 3.3 to 3.4
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_itertools.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 3aed779..993438c 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -985,6 +985,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')),