Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.10] GH-94329: Don't raise on excessive stack consumption (GH-94421) #94448

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,12 @@ def test_func_and(self):
code += " x and x\n" * self.N
self.check_stack_size(code)

def test_stack_3050(self):
M = 3050
code = "x," * M + "=t"
# This raised on 3.10.0 to 3.10.5
compile(code, "<foo>", "single")


class TestStackSizeStability(unittest.TestCase):
# Check that repeating certain snippets doesn't increase the stack size
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Compile and run code with unpacking of extremely large sequences (1000s of elements).
Such code failed to compile. It now compiles and runs correctly.
7 changes: 0 additions & 7 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -6968,13 +6968,6 @@ makecode(struct compiler *c, struct assembler *a, PyObject *consts)
Py_DECREF(consts);
goto error;
}
if (maxdepth > MAX_ALLOWED_STACK_USE) {
PyErr_Format(PyExc_SystemError,
"excessive stack use: stack is %d deep",
maxdepth);
Py_DECREF(consts);
goto error;
}
co = PyCode_NewWithPosOnlyArgs(posonlyargcount+posorkeywordargcount,
posonlyargcount, kwonlyargcount, nlocals_int,
maxdepth, flags, a->a_bytecode, consts, names,
Expand Down