# 类型错误：无法解包非可迭代的 int 对象

- **ID:** `python/typeerror-cannot-unpack-non-iterable`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试函数返回整数，但调用者尝试将其解包为元组或列表。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## 解决方案

1. **Return a tuple instead of int** (95% 成功率)
   ```
   def get_data(): return (1, 2); a, b = get_data()
   ```
2. **Unpack only if iterable** (85% 成功率)
   ```
   result = get_data(); if hasattr(result, '__iter__'): a, b = result
   ```

## 无效尝试

- **Wrapping return value in a list** — If the function returns a single int, wrapping creates a list, but unpacking still expects multiple values. (60% 失败率)
- **Using *args in function definition** — Changes function signature and may break other callers. (40% 失败率)
