diff options
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/ast.c b/Python/ast.c index 2113124dbd5..0c3121d3ee7 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -933,8 +933,9 @@ _PyAST_Validate(mod_ty mod) return 0; } /* Be careful here to prevent overflow. */ - starting_recursion_depth = (tstate->recursion_depth < INT_MAX / COMPILER_STACK_FRAME_SCALE) ? - tstate->recursion_depth * COMPILER_STACK_FRAME_SCALE : tstate->recursion_depth; + int recursion_depth = tstate->recursion_limit - tstate->recursion_remaining; + starting_recursion_depth = (recursion_depth< INT_MAX / COMPILER_STACK_FRAME_SCALE) ? + recursion_depth * COMPILER_STACK_FRAME_SCALE : recursion_depth; state.recursion_depth = starting_recursion_depth; state.recursion_limit = (recursion_limit < INT_MAX / COMPILER_STACK_FRAME_SCALE) ? recursion_limit * COMPILER_STACK_FRAME_SCALE : recursion_limit; |