Skip to content

Commit eefd3d6

Browse files
committed
Change max C recursion to 7000
1 parent 5e50b7e commit eefd3d6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Include/cpython/pystate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ struct _ts {
225225
# define Py_C_RECURSION_LIMIT 500
226226
#else
227227
// This value is duplicated in Lib/test/support/__init__.py
228-
# define Py_C_RECURSION_LIMIT 4500
228+
# define Py_C_RECURSION_LIMIT 7000
229229
#endif
230230

231231

Lib/test/support/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,9 @@ def set_recursion_limit(limit):
21232123

21242124
def infinite_recursion(max_depth=None):
21252125
if max_depth is None:
2126+
# Pick a number large enough to cause problems
2127+
# but not take too long for code that can handle
2128+
# very deep recursion.
21262129
max_depth = 20_000
21272130
elif max_depth < 3:
21282131
raise ValueError("max_depth must be at least 3, got {max_depth}")
@@ -2362,20 +2365,21 @@ def adjust_int_max_str_digits(max_digits):
23622365
finally:
23632366
sys.set_int_max_str_digits(current)
23642367

2365-
#For recursion tests, easily exceeds default recursion limit
2366-
EXCEEDS_RECURSION_LIMIT = 10_000
23672368

23682369
def _get_c_recursion_limit():
23692370
try:
23702371
import _testcapi
23712372
return _testcapi.Py_C_RECURSION_LIMIT
23722373
except (ImportError, AttributeError):
23732374
# Originally taken from Include/cpython/pystate.h .
2374-
return 4500
2375+
return 7000
23752376

23762377
# The default C recursion limit.
23772378
Py_C_RECURSION_LIMIT = _get_c_recursion_limit()
23782379

2380+
#For recursion tests, easily exceeds default recursion limit
2381+
EXCEEDS_RECURSION_LIMIT = Py_C_RECURSION_LIMIT * 3
2382+
23792383
#Windows doesn't have os.uname() but it doesn't support s390x.
23802384
skip_on_s390x = unittest.skipIf(hasattr(os, 'uname') and os.uname().machine == 's390x',
23812385
'skipped on s390x')

0 commit comments

Comments
 (0)