@@ -2112,13 +2112,13 @@ def set_recursion_limit(limit):
21122112 finally :
21132113 sys .setrecursionlimit (original_limit )
21142114
2115- def infinite_recursion (max_depth = 100 ):
2116- """Set a lower limit for tests that interact with infinite recursions
2117- (e.g test_ast.ASTHelpers_Test.test_recursion_direct) since on some
2118- debug windows builds, due to not enough functions being inlined the
2119- stack size might not handle the default recursion limit (1000). See
2120- bpo-11105 for details."""
2121- if max_depth < 3 :
2115+ def infinite_recursion (max_depth = None ):
2116+ if max_depth is None :
2117+ # Pick a number large enough to cause problems
2118+ # but not take too long for code that can handle
2119+ # very deep recursion.
2120+ max_depth = 20_000
2121+ elif max_depth < 3 :
21222122 raise ValueError ("max_depth must be at least 3, got {max_depth}" )
21232123 depth = get_recursion_depth ()
21242124 depth = max (depth - 1 , 1 ) # Ignore infinite_recursion() frame.
@@ -2362,7 +2362,22 @@ def adjust_int_max_str_digits(max_digits):
23622362EXCEEDS_RECURSION_LIMIT = 5000
23632363
23642364# The default C recursion limit (from Include/cpython/pystate.h).
2365- C_RECURSION_LIMIT = 1500
2365+ if Py_DEBUG :
2366+ if is_wasi :
2367+ C_RECURSION_LIMIT = 150
2368+ else :
2369+ C_RECURSION_LIMIT = 500
2370+ else :
2371+ if is_wasi :
2372+ C_RECURSION_LIMIT = 500
2373+ elif hasattr (os , 'uname' ) and os .uname ().machine == 's390x' :
2374+ C_RECURSION_LIMIT = 800
2375+ elif sys .platform .startswith ('win' ):
2376+ C_RECURSION_LIMIT = 3000
2377+ elif check_sanitizer (address = True ):
2378+ C_RECURSION_LIMIT = 4000
2379+ else :
2380+ C_RECURSION_LIMIT = 10000
23662381
23672382#Windows doesn't have os.uname() but it doesn't support s390x.
23682383skip_on_s390x = unittest .skipIf (hasattr (os , 'uname' ) and os .uname ().machine == 's390x' ,
0 commit comments