From f58c366a730ae3e68028dbf63aba7c4033eaec9b Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 30 Jun 2022 07:53:20 -0700 Subject: GH-94329: Don't raise on excessive stack consumption (GH-94421) (GH-94446) (cherry picked from commit b152bf448b321e3a4c0a7280e0b608840f5ac661) --- Lib/test/test_compile.py | 6 ++++++ .../2022-06-29-15-45-04.gh-issue-94329.olUQyk.rst | 2 ++ Python/compile.c | 7 +------ 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-06-29-15-45-04.gh-issue-94329.olUQyk.rst diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index c32c27f..d7c536e 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -1207,6 +1207,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, "", "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 70a754b..1bb0d96 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -8391,12 +8391,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; -- cgit v0.12