mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +00:00
bpo-11105: reduce the recursion limit for tests (GH-26550)
This commit is contained in:
parent
257e400a19
commit
e58d762c1f
2 changed files with 13 additions and 2 deletions
|
@ -1999,3 +1999,12 @@ def check_disallow_instantiation(testcase, tp, *args, **kwds):
|
||||||
qualname = f"{name}"
|
qualname = f"{name}"
|
||||||
msg = f"cannot create '{re.escape(qualname)}' instances"
|
msg = f"cannot create '{re.escape(qualname)}' instances"
|
||||||
testcase.assertRaisesRegex(TypeError, msg, tp, *args, **kwds)
|
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)
|
||||||
|
|
|
@ -1102,6 +1102,7 @@ Module(
|
||||||
e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0)
|
e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0)
|
||||||
e.operand = e
|
e.operand = e
|
||||||
with self.assertRaises(RecursionError):
|
with self.assertRaises(RecursionError):
|
||||||
|
with support.infinite_recursion():
|
||||||
compile(ast.Expression(e), "<test>", "eval")
|
compile(ast.Expression(e), "<test>", "eval")
|
||||||
|
|
||||||
def test_recursion_indirect(self):
|
def test_recursion_indirect(self):
|
||||||
|
@ -1110,6 +1111,7 @@ Module(
|
||||||
e.operand = f
|
e.operand = f
|
||||||
f.operand = e
|
f.operand = e
|
||||||
with self.assertRaises(RecursionError):
|
with self.assertRaises(RecursionError):
|
||||||
|
with support.infinite_recursion():
|
||||||
compile(ast.Expression(e), "<test>", "eval")
|
compile(ast.Expression(e), "<test>", "eval")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue