summaryrefslogtreecommitdiffstats
path: root/Lib/test/list_tests.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-07-25 02:39:20 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-07-25 02:39:20 (GMT)
commitb93d8637a6bce5b1b61423dc6c8319fc82a31b13 (patch)
tree2bf465e8c89e54dc4989f126b7b8c20008e455a9 /Lib/test/list_tests.py
parent32d2ce3561088eb0fbb3e63e9fcbc3a90491604a (diff)
downloadcpython-b93d8637a6bce5b1b61423dc6c8319fc82a31b13.zip
cpython-b93d8637a6bce5b1b61423dc6c8319fc82a31b13.tar.gz
cpython-b93d8637a6bce5b1b61423dc6c8319fc82a31b13.tar.bz2
Issue #1621: Avoid signed overflow in list and tuple operations
Patch by Xiang Zhang.
Diffstat (limited to 'Lib/test/list_tests.py')
-rw-r--r--Lib/test/list_tests.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py
index f20fdc0..26e9368 100644
--- a/Lib/test/list_tests.py
+++ b/Lib/test/list_tests.py
@@ -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)