{
  "id": "python/typeerror-cannot-unpack-non-iterable",
  "signature": "TypeError: cannot unpack non-iterable int object",
  "signature_zh": "类型错误：无法解包非可迭代的 int 对象",
  "regex": "TypeError:\\ cannot\\ unpack\\ non\\-iterable\\ int\\ object",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A test function returns an integer but the caller tries to unpack it as a tuple or list.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试函数返回整数，但调用者尝试将其解包为元组或列表。",
  "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": "Wrapping return value in a list",
      "why_fails": "If the function returns a single int, wrapping creates a list, but unpacking still expects multiple values.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using *args in function definition",
      "why_fails": "Changes function signature and may break other callers.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Return a tuple instead of int",
      "success_rate": 0.95,
      "how": "def get_data(): return (1, 2); a, b = get_data()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Unpack only if iterable",
      "success_rate": 0.85,
      "how": "result = get_data(); if hasattr(result, '__iter__'): a, b = result",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}