# pydantic_core._pydantic_core.ValidationError: 1 validation error for Model
  实例已冻结 [type=frozen_instance, input_value=..., input_type=...]

- **ID:** `python/pydantic-immutability-error`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

模型被定义为 model_config = ConfigDict(frozen=True)，因此创建后任何修改属性的尝试都会引发 frozen_instance。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 2.x | active | — | — |

## 解决方案

1. **** (97% 成功率)
   ```
   new = old.model_copy(update={'name': 'new'})
   ```
2. **** (99% 成功率)
   ```
   class M(BaseModel):
    model_config = ConfigDict(frozen=False)
   ```

## 无效尝试

- **** — Pydantic v2 intercepts __setattr__ at the C level; bypassing breaks hashing invariants. (80% 失败率)
- **** — Works but loses identity and any registered validators may re-run unexpectedly. (40% 失败率)
