Skip to content

Commit f58c366

Browse files
GH-94329: Don't raise on excessive stack consumption (GH-94421) (GH-94446)
(cherry picked from commit b152bf4)
1 parent 48a739e commit f58c366

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
@@ -1207,6 +1207,12 @@ def test_func_and(self):
12071207
code += " x and x\n" * self.N
12081208
self.check_stack_size(code)
12091209

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

12111217
class TestStackSizeStability(unittest.TestCase):
12121218
# 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
@@ -8391,12 +8391,7 @@ assemble(struct compiler *c, int addNone)
83918391
if (maxdepth < 0) {
83928392
goto error;
83938393
}
8394-
if (maxdepth > MAX_ALLOWED_STACK_USE) {
8395-
PyErr_Format(PyExc_SystemError,
8396-
"excessive stack use: stack is %d deep",
8397-
maxdepth);
8398-
goto error;
8399-
}
8394+
/* TO DO -- For 3.12, make sure that `maxdepth <= MAX_ALLOWED_STACK_USE` */
84008395

84018396
if (label_exception_targets(entryblock)) {
84028397
goto error;

0 commit comments

Comments
 (0)