Skip to content

Commit b152bf4

Browse files
authored
GH-94329: Don't raise on excessive stack consumption (GH-94421)
1 parent 9ef50c1 commit b152bf4

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Lib/test/test_compile.py

+6
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,12 @@ def test_func_and(self):
12431243
code += " x and x\n" * self.N
12441244
self.check_stack_size(code)
12451245

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

12471253
class TestStackSizeStability(unittest.TestCase):
12481254
# 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

+1-6
Original file line numberDiff line numberDiff line change
@@ -8652,12 +8652,7 @@ assemble(struct compiler *c, int addNone)
86528652
if (maxdepth < 0) {
86538653
goto error;
86548654
}
8655-
if (maxdepth > MAX_ALLOWED_STACK_USE) {
8656-
PyErr_Format(PyExc_SystemError,
8657-
"excessive stack use: stack is %d deep",
8658-
maxdepth);
8659-
goto error;
8660-
}
8655+
/* TO DO -- For 3.12, make sure that `maxdepth <= MAX_ALLOWED_STACK_USE` */
86618656

86628657
if (label_exception_targets(entryblock)) {
86638658
goto error;

0 commit comments

Comments
 (0)