GH-94329: Don't raise on excessive stack consumption (GH-94421)

This commit is contained in:
Mark Shannon 2022-06-30 15:27:14 +01:00 committed by GitHub
parent 9ef50c1d46
commit b152bf448b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View 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

View file

@ -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.

View 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;