Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 10d6dde

Browse files
committed
Issue #5765: Also check the compiler when finding the recursion limit
1 parent aab9c2b commit 10d6dde

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Tools/scripts/find_recursionlimit.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ def test_cpickle(_cache={}):
8989
_pickle.Pickler(io.BytesIO(), protocol=-1).dump(l)
9090
_cache[n] = l
9191

92+
def test_compiler_recursion():
93+
# The compiler uses a scaling factor to support additional levels
94+
# of recursion. This is a sanity check of that scaling to ensure
95+
# it still throws RuntimeError even at higher recursion limits
96+
compile("()" * (10 * sys.getrecursionlimit()), "<single>", "single")
97+
9298
def check_limit(n, test_func_name):
9399
sys.setrecursionlimit(n)
94100
if test_func_name.startswith("test_"):
@@ -117,5 +123,6 @@ def check_limit(n, test_func_name):
117123
check_limit(limit, "test_getattr")
118124
check_limit(limit, "test_getitem")
119125
check_limit(limit, "test_cpickle")
126+
check_limit(limit, "test_compiler_recursion")
120127
print("Limit of %d is fine" % limit)
121128
limit = limit + 100

0 commit comments

Comments
 (0)