]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-94329: Don't raise on excessive stack consumption (GH-94421)
authorMark Shannon <mark@hotpy.org>
Thu, 30 Jun 2022 14:27:14 +0000 (15:27 +0100)
committerGitHub <noreply@github.com>
Thu, 30 Jun 2022 14:27:14 +0000 (15:27 +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 85b2d82518409c4eca8db67172da701937f4699e..46b16e753ceee2f7b9ece957e09426b1a7796f54 100644 (file)
@@ -1243,6 +1243,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 59f88965bb29c4b97243fd9d8c6666ac48850cb3..2d3b5717eeab55d11383d7be74ebeeead726f736 100644 (file)
@@ -8652,12 +8652,7 @@ assemble(struct compiler *c, int addNone)
     if (maxdepth < 0) {
         goto error;
     }
-    if (maxdepth > MAX_ALLOWED_STACK_USE) {
-        PyErr_Format(PyExc_SystemError,
-                     "excessive stack use: stack is %d deep",
-                     maxdepth);
-        goto error;
-    }
+    /* TO DO -- For 3.12, make sure that `maxdepth <= MAX_ALLOWED_STACK_USE` */
 
     if (label_exception_targets(entryblock)) {
         goto error;