From: Nick Coghlan Date: Sun, 4 Nov 2012 14:19:18 +0000 (+1000) Subject: Issue #5765: Also check the compiler when finding the recursion limit X-Git-Tag: v3.3.1rc1~683 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=10d6ddeef19a69ab9a73e64a3a9a82c50a4160a2;p=python Issue #5765: Also check the compiler when finding the recursion limit --- diff --git a/Tools/scripts/find_recursionlimit.py b/Tools/scripts/find_recursionlimit.py index 7a8660356a..c42de7fc2b 100755 --- a/Tools/scripts/find_recursionlimit.py +++ b/Tools/scripts/find_recursionlimit.py @@ -89,6 +89,12 @@ def test_cpickle(_cache={}): _pickle.Pickler(io.BytesIO(), protocol=-1).dump(l) _cache[n] = l +def test_compiler_recursion(): + # The compiler uses a scaling factor to support additional levels + # of recursion. This is a sanity check of that scaling to ensure + # it still throws RuntimeError even at higher recursion limits + compile("()" * (10 * sys.getrecursionlimit()), "", "single") + def check_limit(n, test_func_name): sys.setrecursionlimit(n) if test_func_name.startswith("test_"): @@ -117,5 +123,6 @@ if __name__ == '__main__': check_limit(limit, "test_getattr") check_limit(limit, "test_getitem") check_limit(limit, "test_cpickle") + check_limit(limit, "test_compiler_recursion") print("Limit of %d is fine" % limit) limit = limit + 100