aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c5
-rw-r--r--Python/ast.c8
-rw-r--r--Python/ast_opt.c7
-rw-r--r--Python/symtable.c9
-rw-r--r--Python/traceback.c6
5 files changed, 13 insertions, 22 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 699e1c157c5..d77e986ba06 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -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);
diff --git a/Python/ast.c b/Python/ast.c
index 5f46d4149c2..71b09d889f1 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -1037,10 +1037,6 @@ validate_type_params(struct validator *state, asdl_type_param_seq *tps)
return 1;
}
-
-/* See comments in symtable.c. */
-#define COMPILER_STACK_FRAME_SCALE 2
-
int
_PyAST_Validate(mod_ty mod)
{
@@ -1057,9 +1053,9 @@ _PyAST_Validate(mod_ty mod)
}
/* Be careful here to prevent overflow. */
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;
state.recursion_depth = starting_recursion_depth;
- state.recursion_limit = Py_C_RECURSION_LIMIT * COMPILER_STACK_FRAME_SCALE;
+ state.recursion_limit = Py_C_RECURSION_LIMIT;
switch (mod->kind) {
case Module_kind:
diff --git a/Python/ast_opt.c b/Python/ast_opt.c
index 04d7ae6eaaf..41e906c66e8 100644
--- a/Python/ast_opt.c
+++ b/Python/ast_opt.c
@@ -1100,9 +1100,6 @@ astfold_type_param(type_param_ty node_, PyArena *ctx_, _PyASTOptimizeState *stat
#undef CALL_OPT
#undef CALL_SEQ
-/* See comments in symtable.c. */
-#define COMPILER_STACK_FRAME_SCALE 2
-
int
_PyAST_Optimize(mod_ty mod, PyArena *arena, int optimize, int ff_features)
{
@@ -1120,9 +1117,9 @@ _PyAST_Optimize(mod_ty mod, PyArena *arena, int optimize, int ff_features)
}
/* Be careful here to prevent overflow. */
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;
state.recursion_depth = starting_recursion_depth;
- state.recursion_limit = Py_C_RECURSION_LIMIT * COMPILER_STACK_FRAME_SCALE;
+ state.recursion_limit = Py_C_RECURSION_LIMIT;
int ret = astfold_mod(mod, arena, &state);
assert(ret || PyErr_Occurred());
diff --git a/Python/symtable.c b/Python/symtable.c
index 83137b491f2..743029956e3 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -386,11 +386,6 @@ symtable_new(void)
return NULL;
}
-/* Using a scaling factor means this should automatically adjust when
- the recursion limit is adjusted for small or large C stack allocations.
-*/
-#define COMPILER_STACK_FRAME_SCALE 2
-
struct symtable *
_PySymtable_Build(mod_ty mod, PyObject *filename, PyFutureFeatures *future)
{
@@ -417,9 +412,9 @@ _PySymtable_Build(mod_ty mod, PyObject *filename, PyFutureFeatures *future)
}
/* Be careful here to prevent overflow. */
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;
st->recursion_depth = starting_recursion_depth;
- st->recursion_limit = Py_C_RECURSION_LIMIT * COMPILER_STACK_FRAME_SCALE;
+ st->recursion_limit = Py_C_RECURSION_LIMIT;
/* Make the initial symbol information gathering pass */
if (!symtable_enter_block(st, &_Py_ID(top), ModuleBlock, (void *)mod, 0, 0, 0, 0)) {
diff --git a/Python/traceback.c b/Python/traceback.c
index abd429ac6c1..7a188e56c93 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -965,7 +965,11 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
unsigned int depth = 0;
while (1) {
if (MAX_FRAME_DEPTH <= depth) {
- PUTS(fd, " ...\n");
+ if (MAX_FRAME_DEPTH < depth) {
+ PUTS(fd, "plus ");
+ _Py_DumpDecimal(fd, depth);
+ PUTS(fd, " frames\n");
+ }
break;
}
dump_frame(fd, frame);