]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] GH-94329: Don't raise on excessive stack consumption (GH-94421) (#94448)
authorMark Shannon <mark@hotpy.org>
Mon, 11 Jul 2022 12:21:17 +0000 (13:21 +0100)
committerGitHub <noreply@github.com>
Mon, 11 Jul 2022 12:21:17 +0000 (13:21 +0100)
Lib/test/test_compile.py
Misc/NEWS.d/next/Core and Builtins/2022-06-29-15-45-04.gh-issue-94329.olUQyk.rst [new file with mode: 0644]
Python/compile.c

index 9859d9a46710d31e7bc8c3c2949124e04239716b..8312613aeaa9f1fab0a4b8e40815cd55ef331953 100644 (file)
@@ -1035,6 +1035,12 @@ class TestExpressionStackSize(unittest.TestCase):
         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
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-06-29-15-45-04.gh-issue-94329.olUQyk.rst b/Misc/NEWS.d/next/Core and Builtins/2022-06-29-15-45-04.gh-issue-94329.olUQyk.rst
new file mode 100644 (file)
index 0000000..afd31b6
--- /dev/null
@@ -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.
index ea2fdfdb60405f0d0837e5e2a7d0861620768370..40d1761804b71f502e9580fc346c3d1ac1300567 100644 (file)
@@ -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,