{
  "id": "python/pytest-recursion-error-in-fixture",
  "signature": "RecursionError: maximum recursion depth exceeded while calling a Python object",
  "signature_zh": "RecursionError: 调用 Python 对象时超出最大递归深度",
  "regex": "RecursionError:\\ maximum\\ recursion\\ depth\\ exceeded\\ while\\ calling\\ a\\ Python\\ object",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A fixture directly or indirectly depends on itself, causing infinite recursion during fixture resolution. This often happens when a fixture has the same name as a parameter it requests.",
  "root_cause_type": "generic",
  "root_cause_zh": "夹具直接或间接依赖自身，导致夹具解析期间无限递归。这通常发生在夹具名称与其请求的参数名称相同时。",
  "versions": [
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This delays the inevitable crash and may cause a stack overflow, potentially crashing the Python interpreter.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "RecursionError occurs during fixture resolution, before the fixture body executes. The try/except inside the fixture never catches it.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "@pytest.fixture\ndef db_connection():\n    return create_connection()\n\n@pytest.fixture\ndef db_session(db_connection):  # Different name\n    return Session(db_connection)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "@pytest.fixture\ndef my_fixture(request):\n    other = request.getfixturevalue('other_fixture')\n    return process(other)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}