Skip to content

Commit b87d03d

Browse files
authored
[3.10] GH-94329: Don't raise on excessive stack consumption (GH-94421) (#94448)
1 parent 30015de commit b87d03d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Lib/test/test_compile.py

+6
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,12 @@ def test_func_and(self):
10351035
code += " x and x\n" * self.N
10361036
self.check_stack_size(code)
10371037

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

10391045
class TestStackSizeStability(unittest.TestCase):
10401046
# Check that repeating certain snippets doesn't increase the stack size
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Compile and run code with unpacking of extremely large sequences (1000s of elements).
2+
Such code failed to compile. It now compiles and runs correctly.

Python/compile.c

-7
Original file line numberDiff line numberDiff line change
@@ -6968,13 +6968,6 @@ makecode(struct compiler *c, struct assembler *a, PyObject *consts)
69686968
Py_DECREF(consts);
69696969
goto error;
69706970
}
6971-
if (maxdepth > MAX_ALLOWED_STACK_USE) {
6972-
PyErr_Format(PyExc_SystemError,
6973-
"excessive stack use: stack is %d deep",
6974-
maxdepth);
6975-
Py_DECREF(consts);
6976-
goto error;
6977-
}
69786971
co = PyCode_NewWithPosOnlyArgs(posonlyargcount+posorkeywordargcount,
69796972
posonlyargcount, kwonlyargcount, nlocals_int,
69806973
maxdepth, flags, a->a_bytecode, consts, names,

0 commit comments

Comments
 (0)