{
  "id": "python/stopiteration-next-on-empty-generator",
  "signature": "StopIteration: ",
  "signature_zh": "停止迭代：",
  "regex": "StopIteration:\\ ",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling next() on a generator or iterator that has no more items, without a default value.",
  "root_cause_type": "generic",
  "root_cause_zh": "在没有默认值的情况下对没有更多项的生成器或迭代器调用 next()。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Catching StopIteration with a bare except",
      "why_fails": "Bare except catches all exceptions, potentially hiding other bugs.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using list(iterator) without checking length",
      "why_fails": "list() consumes the iterator but does not handle empty case gracefully.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Provide default value to next()",
      "success_rate": 0.95,
      "how": "item = next(generator, None)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use for loop instead of next()",
      "success_rate": 0.9,
      "how": "for item in generator:\n    process(item)",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-04-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}