summaryrefslogtreecommitdiff
path: root/Lib/test/test_list.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_list.py')
-rw-r--r--Lib/test/test_list.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py
index 105ef650ee..75ecc70b0b 100644
--- a/Lib/test/test_list.py
+++ b/Lib/test/test_list.py
@@ -68,6 +68,19 @@ class ListTest(list_tests.CommonTest):
self.assertRaises((MemoryError, OverflowError), mul, lst, n)
self.assertRaises((MemoryError, OverflowError), imul, lst, n)
+ def test_list_resize_overflow(self):
+ # gh-97616: test new_allocated * sizeof(PyObject*) overflow
+ # check in list_resize()
+ lst = [0] * 65
+ del lst[1:]
+ self.assertEqual(len(lst), 1)
+
+ size = ((2 ** (tuple.__itemsize__ * 8) - 1) // 2)
+ with self.assertRaises((MemoryError, OverflowError)):
+ lst * size
+ with self.assertRaises((MemoryError, OverflowError)):
+ lst *= size
+
def test_repr_large(self):
# Check the repr of large list objects
def check(n):