# pydantic_core._pydantic_core.ValidationError: 1 个验证错误 (Config)
field_name
  实例已冻结 [type=frozen_instance, input_value='new', input_type=str]

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

## 根因

尝试修改设置了 `model_config = ConfigDict(frozen=True)` 的模型属性。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Use `model_copy(update={'field_name': 'new'})` to produce a new instance.
   ```
2. **** (85% 成功率)
   ```
   Remove `frozen=True` if mutability is required, or use `object.__setattr__(obj, 'field_name', 'new')` as a last resort.
   ```

## 无效尝试

- **** — Using `setattr` bypasses type checkers but still raises at runtime. (90% 失败率)
- **** — Mutating `__dict__` directly works but breaks hashing and Pydantic invariants. (70% 失败率)
