# 递归错误：调用 Python 对象时超过最大递归深度

- **ID:** `python/recursionerror-maximum-recursion-depth`
- **领域:** python
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试函数或 fixture 在没有基本情况的情况下递归调用自身，或模拟设置导致无限递归。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## 解决方案

1. **Add a base case to recursive function** (95% 成功率)
   ```
   def recursive_func(n):
    if n <= 0: return
    recursive_func(n-1)
   ```
2. **Use iterative approach instead of recursion** (90% 成功率)
   ```
   def iterative_func(n):
    while n > 0:
        n -= 1
   ```

## 无效尝试

- **Increasing recursion limit with sys.setrecursionlimit** — Postpones the problem; may cause stack overflow or crash. (70% 失败率)
- **Ignoring the error** — The test will always fail until recursion is fixed. (90% 失败率)
