Issue #1621: Avoid signed overflow in list and tuple operations

Patch by Xiang Zhang.
This commit is contained in:
Martin Panter 2016-07-25 02:39:20 +00:00
parent 32d2ce3561
commit b93d8637a6
4 changed files with 28 additions and 11 deletions

View file

@ -266,9 +266,21 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(a, list("spameggs"))
self.assertRaises(TypeError, a.extend, None)
self.assertRaises(TypeError, a.extend)
# overflow test. issue1621
class CustomIter:
def __iter__(self):
return self
def __next__(self):
raise StopIteration
def __length_hint__(self):
return sys.maxsize
a = self.type2test([1,2,3,4])
a.extend(CustomIter())
self.assertEqual(a, [1,2,3,4])
def test_insert(self):
a = self.type2test([0, 1, 2])
a.insert(0, -2)