{
  "id": "python/pytest-collection-recursion-error",
  "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": "pytest's collection traverses symlinked directories or a conftest.py imports a module that imports pytest itself, causing infinite recursion during collection.",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest 的收集过程遍历符号链接目录，或 conftest.py 导入了一个反过来导入 pytest 的模块，导致收集期间无限递归。",
  "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": "Delays the crash and may segfault; does not fix the underlying cycle.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Only fixes one specific symlink; other cycles remain.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Find and remove symlink loops:\n\nfind tests -type l -exec sh -c 'readlink -f \"$1\" | grep -q \"$(dirname $1)\" && echo $1' _ {} \\;",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Break the import cycle in conftest.py by moving shared helpers into a separate module that does not import pytest.",
      "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.8,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2026-01-09",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}