Skip to content

Commit

Permalink
pythongh-111798: Use lower Py_C_RECURSION_LIMIT in debug mode
Browse files Browse the repository at this point in the history
Reenable test_call.test_super_deep() on s390x architecture.
  • Loading branch information
vstinner committed Nov 15, 2023
1 parent e5dfcc2 commit 35e985e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ struct _ts {

};

#ifdef __wasi__
#ifdef Py_DEBUG
// A debug build is likely built with low optimization level which implies
// higher stack memory usage than a release build. Use a lower limit.
# define Py_C_RECURSION_LIMIT 500
#elif defined(__wasi__)
// WASI has limited call stack. Python's recursion limit depends on code
// layout, optimization, and WASI runtime. Wasmtime can handle about 700
// recursions, sometimes less. 500 is a more conservative limit.
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_call.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from test.support import cpython_only, requires_limited_api, skip_on_s390x
from test.support import cpython_only, requires_limited_api
try:
import _testcapi
except ImportError:
Expand Down Expand Up @@ -989,7 +989,6 @@ def case_change_over_substitution(BLuch=None, Luch = None, fluch = None):
@cpython_only
class TestRecursion(unittest.TestCase):

@skip_on_s390x
def test_super_deep(self):

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

0 comments on commit 35e985e

Please sign in to comment.