mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
GH-113655: Lower the C recursion limit on various platforms (GH-113944)
This commit is contained in:
parent
6c502ba809
commit
17b73ab99e
13 changed files with 41 additions and 39 deletions
5
Python/Python-ast.c
generated
5
Python/Python-ast.c
generated
|
@ -13149,15 +13149,14 @@ PyObject* PyAST_mod2obj(mod_ty t)
|
|||
|
||||
int starting_recursion_depth;
|
||||
/* Be careful here to prevent overflow. */
|
||||
int COMPILER_STACK_FRAME_SCALE = 2;
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
if (!tstate) {
|
||||
return NULL;
|
||||
}
|
||||
struct validator vstate;
|
||||
vstate.recursion_limit = Py_C_RECURSION_LIMIT * COMPILER_STACK_FRAME_SCALE;
|
||||
vstate.recursion_limit = Py_C_RECURSION_LIMIT;
|
||||
int recursion_depth = Py_C_RECURSION_LIMIT - tstate->c_recursion_remaining;
|
||||
starting_recursion_depth = recursion_depth * COMPILER_STACK_FRAME_SCALE;
|
||||
starting_recursion_depth = recursion_depth;
|
||||
vstate.recursion_depth = starting_recursion_depth;
|
||||
|
||||
PyObject *result = ast2obj_mod(state, &vstate, t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue