{
  "id": "python/pytest-doctest-capture-stdout",
  "signature": "Failed: DID NOT RAISE <class 'SystemExit'>\nUNEXPECTED EXCEPTION: SystemExit(0)",
  "signature_zh": "失败：未引发 <class 'SystemExit'>\n意外异常：SystemExit(0)",
  "regex": "Failed:\\ DID\\ NOT\\ RAISE\\ <class\\ 'SystemExit'>\\\nUNEXPECTED\\ EXCEPTION:\\ SystemExit\\(0\\)",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A doctest that calls sys.exit() or argparse with --help exits the interpreter; doctest expects a return value, not a process exit.",
  "root_cause_type": "generic",
  "root_cause_zh": "调用 sys.exit() 或带 --help 的 argparse 的 doctest 退出了解释器；doctest 期望返回值，而不是进程退出。",
  "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": "Continues after failure but doesn't prevent SystemExit.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "In doctest source, suppress changes the observable output.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides a real usability bug in the CLI.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": ">>> import sys\n>>> try:\n...     main([\"--help\"])\n... except SystemExit as e:\n...     print(\"exit\", e.code)\nexit 0",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "def main(argv=None) -> int:\n    ...\n    return 0\n\nif __name__ == \"__main__\":\n    raise SystemExit(main())",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-12-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}