From: Serhiy Storchaka Date: Tue, 9 Jan 2018 19:54:52 +0000 (+0200) Subject: bpo-24340: Fix estimation of the code stack size. (#5076) X-Git-Tag: v3.7.0b1~195 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d4864c61e3e27e337762dc45e504977299bd5b46;p=thirdparty%2FPython%2Fcpython.git bpo-24340: Fix estimation of the code stack size. (#5076) --- diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index ae3043af0bd2..29aa362590f7 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -672,7 +672,7 @@ if 1: compile("42", PathLike("test_compile_pathlike"), "single") -class TestStackSize(unittest.TestCase): +class TestExpressionStackSize(unittest.TestCase): # These tests check that the computed stack size for a code object # stays within reasonable bounds (see issue #21523 for an example # dysfunction). @@ -710,5 +710,294 @@ class TestStackSize(unittest.TestCase): self.check_stack_size(code) +class TestStackSizeStability(unittest.TestCase): + # Check that repeating certain snippets doesn't increase the stack size + # beyond what a single snippet requires. + + def check_stack_size(self, snippet, async_=False): + def compile_snippet(i): + ns = {} + script = """def func():\n""" + i * snippet + if async_: + script = "async " + script + code = compile(script, "