MCPcopy Index your code
hub / github.com/python/cpython / infinite_recursion

Function infinite_recursion

Lib/test/support/__init__.py:2515–2526  ·  view source on GitHub ↗
(max_depth=None)

Source from the content-addressed store, hash-verified

2513 sys.setrecursionlimit(original_limit)
2514
2515def infinite_recursion(max_depth=None):
2516 if max_depth is None:
2517 # Pick a number large enough to cause problems
2518 # but not take too long for code that can handle
2519 # very deep recursion.
2520 max_depth = 20_000
2521 elif max_depth < 3:
2522 raise ValueError(f"max_depth must be at least 3, got {max_depth}")
2523 depth = get_recursion_depth()
2524 depth = max(depth - 1, 1) # Ignore infinite_recursion() frame.
2525 limit = depth + max_depth
2526 return set_recursion_limit(limit)
2527
2528def ignore_deprecations_from(module: str, *, like: str) -> object:
2529 token = object()

Calls 2

get_recursion_depthFunction · 0.85
set_recursion_limitFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…