@@ -2122,19 +2122,11 @@ def set_recursion_limit(limit):
2122
2122
sys .setrecursionlimit (original_limit )
2123
2123
2124
2124
def infinite_recursion (max_depth = None ):
2125
- """Set a lower limit for tests that interact with infinite recursions
2126
- (e.g test_ast.ASTHelpers_Test.test_recursion_direct) since on some
2127
- debug windows builds, due to not enough functions being inlined the
2128
- stack size might not handle the default recursion limit (1000). See
2129
- bpo-11105 for details."""
2130
2125
if max_depth is None :
2131
- if not python_is_optimized () or Py_DEBUG :
2132
- # Python built without compiler optimizations or in debug mode
2133
- # usually consumes more stack memory per function call.
2134
- # Unoptimized number based on what works under a WASI debug build.
2135
- max_depth = 50
2136
- else :
2137
- max_depth = 100
2126
+ # Pick a number large enough to cause problems
2127
+ # but not take too long for code that can handle
2128
+ # very deep recursion.
2129
+ max_depth = 20_000
2138
2130
elif max_depth < 3 :
2139
2131
raise ValueError ("max_depth must be at least 3, got {max_depth}" )
2140
2132
depth = get_recursion_depth ()
@@ -2373,20 +2365,21 @@ def adjust_int_max_str_digits(max_digits):
2373
2365
finally :
2374
2366
sys .set_int_max_str_digits (current )
2375
2367
2376
- #For recursion tests, easily exceeds default recursion limit
2377
- EXCEEDS_RECURSION_LIMIT = 5000
2378
2368
2379
2369
def _get_c_recursion_limit ():
2380
2370
try :
2381
2371
import _testcapi
2382
2372
return _testcapi .Py_C_RECURSION_LIMIT
2383
2373
except (ImportError , AttributeError ):
2384
2374
# Originally taken from Include/cpython/pystate.h .
2385
- return 1500
2375
+ return 8000
2386
2376
2387
2377
# The default C recursion limit.
2388
2378
Py_C_RECURSION_LIMIT = _get_c_recursion_limit ()
2389
2379
2380
+ #For recursion tests, easily exceeds default recursion limit
2381
+ EXCEEDS_RECURSION_LIMIT = Py_C_RECURSION_LIMIT * 3
2382
+
2390
2383
#Windows doesn't have os.uname() but it doesn't support s390x.
2391
2384
skip_on_s390x = unittest .skipIf (hasattr (os , 'uname' ) and os .uname ().machine == 's390x' ,
2392
2385
'skipped on s390x' )
0 commit comments