GH-91079: Decouple C stack overflow checks from Python recursion checks. (GH-96510)

This commit is contained in:
Mark Shannon 2022-10-05 01:34:03 +01:00 committed by GitHub
parent 0ff8fd6583
commit 76449350b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 165 additions and 99 deletions

View file

@ -1372,6 +1372,7 @@ class ExceptionTests(unittest.TestCase):
code = """if 1:
import sys
from _testinternalcapi import get_recursion_depth
from test import support
class MyException(Exception): pass
@ -1399,13 +1400,8 @@ class ExceptionTests(unittest.TestCase):
generator = gen()
next(generator)
recursionlimit = sys.getrecursionlimit()
depth = get_recursion_depth()
try:
# Upon the last recursive invocation of recurse(),
# tstate->recursion_depth is equal to (recursion_limit - 1)
# and is equal to recursion_limit when _gen_throw() calls
# PyErr_NormalizeException().
recurse(setrecursionlimit(depth + 2) - depth)
recurse(support.EXCEEDS_RECURSION_LIMIT)
finally:
sys.setrecursionlimit(recursionlimit)
print('Done.')