mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
GH-111808: Make the default value for test.support.infinite_recursion()
conditional on compiler optimizations (GH-112223)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
dabc0d77b2
commit
f489ace9e7
4 changed files with 16 additions and 4 deletions
|
@ -2120,13 +2120,21 @@ def set_recursion_limit(limit):
|
|||
finally:
|
||||
sys.setrecursionlimit(original_limit)
|
||||
|
||||
def infinite_recursion(max_depth=100):
|
||||
def infinite_recursion(max_depth=None):
|
||||
"""Set a lower limit for tests that interact with infinite recursions
|
||||
(e.g test_ast.ASTHelpers_Test.test_recursion_direct) since on some
|
||||
debug windows builds, due to not enough functions being inlined the
|
||||
stack size might not handle the default recursion limit (1000). See
|
||||
bpo-11105 for details."""
|
||||
if max_depth < 3:
|
||||
if max_depth is None:
|
||||
if not python_is_optimized() or Py_DEBUG:
|
||||
# Python built without compiler optimizations or in debug mode
|
||||
# usually consumes more stack memory per function call.
|
||||
# Unoptimized number based on what works under a WASI debug build.
|
||||
max_depth = 50
|
||||
else:
|
||||
max_depth = 100
|
||||
elif max_depth < 3:
|
||||
raise ValueError("max_depth must be at least 3, got {max_depth}")
|
||||
depth = get_recursion_depth()
|
||||
depth = max(depth - 1, 1) # Ignore infinite_recursion() frame.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue