diff options
author | Mark Shannon <mark@hotpy.org> | 2022-07-11 12:21:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 12:21:17 (GMT) |
commit | b87d03d355a1b303a1e0550b0da0fdeb99674da5 (patch) | |
tree | 37bc5a375548656bb4044ca8b9299ef08c7f5636 | |
parent | 30015de7235e5b4033298b85a164fcd8d96046b3 (diff) | |
download | cpython-b87d03d355a1b303a1e0550b0da0fdeb99674da5.zip cpython-b87d03d355a1b303a1e0550b0da0fdeb99674da5.tar.gz cpython-b87d03d355a1b303a1e0550b0da0fdeb99674da5.tar.bz2 |
[3.10] GH-94329: Don't raise on excessive stack consumption (GH-94421) (#94448)
-rw-r--r-- | Lib/test/test_compile.py | 6 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2022-06-29-15-45-04.gh-issue-94329.olUQyk.rst | 2 | ||||
-rw-r--r-- | Python/compile.c | 7 |
3 files changed, 8 insertions, 7 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 9859d9a..8312613 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -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 index 0000000..afd31b6 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-06-29-15-45-04.gh-issue-94329.olUQyk.rst @@ -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. diff --git a/Python/compile.c b/Python/compile.c index ea2fdfd..40d1761 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -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, |