bpo-11105: reduce the recursion limit for tests (GH-26550)

This commit is contained in:
Batuhan Taskaya 2021-06-08 19:55:10 +03:00 committed by GitHub
parent 257e400a19
commit e58d762c1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -1999,3 +1999,12 @@ def check_disallow_instantiation(testcase, tp, *args, **kwds):
qualname = f"{name}"
msg = f"cannot create '{re.escape(qualname)}' instances"
testcase.assertRaisesRegex(TypeError, msg, tp, *args, **kwds)
@contextlib.contextmanager
def infinite_recursion(max_depth=75):
original_depth = sys.getrecursionlimit()
try:
sys.setrecursionlimit(max_depth)
yield
finally:
sys.setrecursionlimit(original_depth)