Skip to content

Commit 91f95de

Browse files
committed
remove test that cannot overflow now
1 parent 3130f94 commit 91f95de

File tree

2 files changed

+0
-52
lines changed

2 files changed

+0
-52
lines changed

Lib/test/test_frame.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -222,29 +222,6 @@ def test_f_lineno_del_segfault(self):
222222
with self.assertRaises(AttributeError):
223223
del f.f_lineno
224224

225-
@unittest.skipUnless(_testcapi, "requires _testcapi")
226-
def test_sizeof_overflow(self):
227-
# See: https://github.com/python/cpython/issues/126119
228-
ctypes = import_helper.import_module('ctypes')
229-
230-
f, _, _ = self.make_frames()
231-
c = f.f_code
232-
co_nlocalsplus = len({*c.co_varnames, *c.co_cellvars, *c.co_freevars})
233-
234-
fss = support.get_frame_specials_size()
235-
ps = ctypes.sizeof(ctypes.c_void_p) # sizeof(PyObject *)
236-
evil_stacksize = int(_testcapi.INT_MAX / ps - fss - co_nlocalsplus)
237-
# an evil code with a valid (but very large) stack size
238-
evil_code = f.f_code.replace(co_stacksize=evil_stacksize - 1)
239-
240-
if sys.maxsize == 2147483647: # 32-bit machine
241-
with self.assertRaises(MemoryError):
242-
frame = _testcapi.frame_new(evil_code, globals(), locals())
243-
else:
244-
frame = _testcapi.frame_new(evil_code, globals(), locals())
245-
message = re.escape("size exceeds INT_MAX")
246-
self.assertRaisesRegex(OverflowError, message, frame.__sizeof__)
247-
248225

249226
class ReprTest(unittest.TestCase):
250227
"""

Lib/test/test_generators.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import copy
22
import gc
33
import pickle
4-
import re
54
import sys
65
import doctest
76
import unittest
@@ -11,7 +10,6 @@
1110
import types
1211

1312
from test import support
14-
from test.support import import_helper
1513

1614
try:
1715
import _testcapi
@@ -270,33 +268,6 @@ def loop():
270268
#This should not raise
271269
loop()
272270

273-
@unittest.skipUnless(_testcapi, "requires _testcapi")
274-
def test_gi_frame_f_code_overflow(self):
275-
# See: https://github.com/python/cpython/issues/126119
276-
ctypes = import_helper.import_module('ctypes')
277-
278-
def f(): yield
279-
c = f().gi_frame.f_code
280-
co_nlocalsplus = len({*c.co_varnames, *c.co_cellvars, *c.co_freevars})
281-
282-
ps = ctypes.sizeof(ctypes.c_void_p) # sizeof(PyObject *)
283-
fss = support.get_frame_specials_size()
284-
# anything below that limit is a valid co_stacksize
285-
evil_stacksize = int(_testcapi.INT_MAX / ps - fss - co_nlocalsplus)
286-
287-
evil = c.__replace__(co_stacksize=evil_stacksize - 1)
288-
289-
if support.Py_GIL_DISABLED:
290-
self.skipTest("segmentation fault on free-threaded builds")
291-
elif sys.maxsize == 2147483647: # 32-bit machine
292-
with self.assertRaises(MemoryError):
293-
evil_gi = types.FunctionType(evil, {})()
294-
else:
295-
# the following crashes on free-threaded builds for now
296-
evil_gi = types.FunctionType(evil, {})()
297-
message = re.escape("size exceeds INT_MAX")
298-
self.assertRaisesRegex(OverflowError, message, evil_gi.__sizeof__)
299-
300271

301272
class ModifyUnderlyingIterableTest(unittest.TestCase):
302273
iterables = [

0 commit comments

Comments
 (0)