Skip to content

Commit 35e985e

Browse files
committed
pythongh-111798: Use lower Py_C_RECURSION_LIMIT in debug mode
Reenable test_call.test_super_deep() on s390x architecture.
1 parent e5dfcc2 commit 35e985e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Include/cpython/pystate.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ struct _ts {
214214

215215
};
216216

217-
#ifdef __wasi__
217+
#ifdef Py_DEBUG
218+
// A debug build is likely built with low optimization level which implies
219+
// higher stack memory usage than a release build. Use a lower limit.
220+
# define Py_C_RECURSION_LIMIT 500
221+
#elif defined(__wasi__)
218222
// WASI has limited call stack. Python's recursion limit depends on code
219223
// layout, optimization, and WASI runtime. Wasmtime can handle about 700
220224
// recursions, sometimes less. 500 is a more conservative limit.

Lib/test/test_call.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import unittest
2-
from test.support import cpython_only, requires_limited_api, skip_on_s390x
2+
from test.support import cpython_only, requires_limited_api
33
try:
44
import _testcapi
55
except ImportError:
@@ -989,7 +989,6 @@ def case_change_over_substitution(BLuch=None, Luch = None, fluch = None):
989989
@cpython_only
990990
class TestRecursion(unittest.TestCase):
991991

992-
@skip_on_s390x
993992
def test_super_deep(self):
994993

995994
def recurse(n):
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
When Python is built in debug mode, set the C recursion limit to 500 instead
2+
of 1500. A debug build is likely built with low optimization level which
3+
implies higher stack memory usage than a release build. Patch by Victor
4+
Stinner.

0 commit comments

Comments
 (0)