mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #5765: Also check the compiler when finding the recursion limit
This commit is contained in:
parent
aab9c2b2ea
commit
10d6ddeef1
1 changed files with 7 additions and 0 deletions
|
@ -89,6 +89,12 @@ def test_cpickle(_cache={}):
|
||||||
_pickle.Pickler(io.BytesIO(), protocol=-1).dump(l)
|
_pickle.Pickler(io.BytesIO(), protocol=-1).dump(l)
|
||||||
_cache[n] = 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>", "single")
|
||||||
|
|
||||||
def check_limit(n, test_func_name):
|
def check_limit(n, test_func_name):
|
||||||
sys.setrecursionlimit(n)
|
sys.setrecursionlimit(n)
|
||||||
if test_func_name.startswith("test_"):
|
if test_func_name.startswith("test_"):
|
||||||
|
@ -117,5 +123,6 @@ if __name__ == '__main__':
|
||||||
check_limit(limit, "test_getattr")
|
check_limit(limit, "test_getattr")
|
||||||
check_limit(limit, "test_getitem")
|
check_limit(limit, "test_getitem")
|
||||||
check_limit(limit, "test_cpickle")
|
check_limit(limit, "test_cpickle")
|
||||||
|
check_limit(limit, "test_compiler_recursion")
|
||||||
print("Limit of %d is fine" % limit)
|
print("Limit of %d is fine" % limit)
|
||||||
limit = limit + 100
|
limit = limit + 100
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue