Skip to content

Commit 00c2ce2

Browse files
[3.15] gh-158660: Test PyList_New() check on integer overflow (GH-162704) (#162739)
gh-158660: Test PyList_New() check on integer overflow (GH-162704) (cherry picked from commit 806d492) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 47bbbb8 commit 00c2ce2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎Lib/test/test_capi/test_list.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import unittest
23
from test.support import import_helper
34
from collections import UserList
@@ -58,6 +59,9 @@ def test_list_new(self):
5859
self.assertIsNot(lst2, lst)
5960
self.assertRaises(SystemError, list_new, NULL)
6061
self.assertRaises(SystemError, list_new, -1)
62+
max_nitem = sys.maxsize // _testcapi.SIZEOF_VOID_P
63+
self.assertRaises(MemoryError, list_new, max_nitem + 1)
64+
self.assertRaises(MemoryError, list_new, sys.maxsize)
6165

6266
def test_list_size(self):
6367
# Test PyList_Size()

0 commit comments

Comments
 (0)