diff options
author | Batuhan Taskaya <batuhan@python.org> | 2021-06-08 16:55:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-08 16:55:10 (GMT) |
commit | e58d762c1fb4ad5e021d016c80c2bc4513632d2f (patch) | |
tree | 4eb76e44c9d9bc6e1297a38335c91a655ea7e2a2 /Lib/test/support | |
parent | 257e400a19b34c7da6e2aa500d80b54e4c4dbf6f (diff) | |
download | cpython-e58d762c1fb4ad5e021d016c80c2bc4513632d2f.zip cpython-e58d762c1fb4ad5e021d016c80c2bc4513632d2f.tar.gz cpython-e58d762c1fb4ad5e021d016c80c2bc4513632d2f.tar.bz2 |
bpo-11105: reduce the recursion limit for tests (GH-26550)
Diffstat (limited to 'Lib/test/support')
-rw-r--r-- | Lib/test/support/__init__.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 34a9459..d17331e 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -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) |