]> granicus.if.org Git - python/commitdiff
Issue #25021: Merge from 3.3 to 3.4
authorKristján Valur Jónsson <sweskman@gmail.com>
Sat, 12 Sep 2015 15:30:23 +0000 (15:30 +0000)
committerKristján Valur Jónsson <sweskman@gmail.com>
Sat, 12 Sep 2015 15:30:23 +0000 (15:30 +0000)
1  2 
Lib/test/test_itertools.py
Modules/itertoolsmodule.c

index 3aed77988e1260ef11b927a5c57407905aa8d1c7,35391c96b4e1452960f3817c1441c0c55a768e4b..993438c9ce3cfcde893dabe0f5c4dc12bbb7555a
@@@ -982,9 -957,18 +982,19 @@@ class TestBasicOps(unittest.TestCase)
              ]:
              self.assertEqual(list(copy.copy(product(*args))), result)
              self.assertEqual(list(copy.deepcopy(product(*args))), result)
 -            self.pickletest(product(*args))
 +            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')),
Simple merge