|
1 | 1 | import copy |
2 | 2 | import gc |
3 | 3 | import pickle |
4 | | -import re |
5 | 4 | import sys |
6 | 5 | import doctest |
7 | 6 | import unittest |
|
11 | 10 | import types |
12 | 11 |
|
13 | 12 | from test import support |
14 | | -from test.support import import_helper |
15 | 13 |
|
16 | 14 | try: |
17 | 15 | import _testcapi |
@@ -270,33 +268,6 @@ def loop(): |
270 | 268 | #This should not raise |
271 | 269 | loop() |
272 | 270 |
|
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 | | - |
300 | 271 |
|
301 | 272 | class ModifyUnderlyingIterableTest(unittest.TestCase): |
302 | 273 | iterables = [ |
|
0 commit comments