# pydantic_core._pydantic_core.ValidationError：1 个验证错误（Config）
__root__
  实例已冻结 [type=frozen_instance, input_value=Config(x=1), input_type=Config]

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

## 根因

模型声明为 model_config = ConfigDict(frozen=True)，但构造后代码尝试修改其属性。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   c2 = c.model_copy(update={'x': 2})
assert c2.x == 2 and c.x == 1
   ```
2. **** (90% 成功率)
   ```
   from pydantic import BaseModel, ConfigDict
class Config(BaseModel):
    model_config = ConfigDict(frozen=False)
    x: int
   ```

## 无效尝试

- **** — There is no override; frozen is enforced via pydantic-core in Rust. (70% 失败率)
- **** — Bypasses validation and hash consistency, breaking dict/set usage of the model. (60% 失败率)
- **** — model_config is class-level; mutating it affects all instances and is not thread-safe. (45% 失败率)
