mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Issue #1621: Avoid signed overflow in list and tuple operations
Patch by Xiang Zhang.
This commit is contained in:
parent
32d2ce3561
commit
b93d8637a6
4 changed files with 28 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue