(max_depth=None)
| 2513 | sys.setrecursionlimit(original_limit) |
| 2514 | |
| 2515 | def 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 | |
| 2528 | def ignore_deprecations_from(module: str, *, like: str) -> object: |
| 2529 | token = object() |
searching dependent graphs…