Skip to content

Commit

Permalink
Update Lib/test/support/__init__.py
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
brettcannon and vstinner authored Nov 17, 2023
1 parent 840fcfc commit ba7e8c3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2115,8 +2115,13 @@ def infinite_recursion(max_depth=None):
stack size might not handle the default recursion limit (1000). See
bpo-11105 for details."""
if max_depth is None:
# Unoptimized number based on what works under a WASI debug build.
max_depth = 100 if python_is_optimized() else 50
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()
Expand Down

0 comments on commit ba7e8c3

Please sign in to comment.