The Fix
pip install pydantic==1.10.19
Based on closed pydantic/pydantic issue #10573 · PR/commit linked
@@ -848,6 +848,10 @@ def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self:
return m
+ def __replace__(self, **changes: Any) -> Self:
+ """Creates a new instance of the model, replacing fields with values from changes. Relevant for v3.13+."""
+ return self.model_copy(update=changes)
import copy
from pydantic import BaseModel
class MyModel(BaseModel):
name: str
color: str
a = MyModel(name="a", color="blue")
b = copy.replace(a, color="red')
print(a)
# MyModel(name='a', color='blue')
print(b)
# MyModel(name='a', color='red')
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install pydantic==1.10.19\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n
Why This Fix Works in Production
- Trigger: - [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
- Mechanism: Adds support for Python 3.13's new `__replace__` protocol in Pydantic's BaseModel, allowing models to be used with `copy.replace()`.
- Why the fix works: Adds support for Python 3.13's new `__replace__` protocol in Pydantic's BaseModel, allowing models to be used with `copy.replace()`. (first fixed release: 1.10.19).
Why This Breaks in Prod
- Shows up under Python 3.13 in real deployments (not just unit tests).
- Production symptom (often without a traceback): - [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
Proof / Evidence
- GitHub issue: #10573
- Fix PR: https://github.com/pydantic/pydantic/pull/10596
- First fixed release: 1.10.19
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.56
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I've opened a PR adding support for this that'll land in v2.10!”
Failure Signature (Search String)
- - [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
- - [ ] [Data validation/parsing](https://docs.pydantic.dev/concepts/models/#basic-model-usage)
Copy-friendly signature
Failure Signature
-----------------
- [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
- [ ] [Data validation/parsing](https://docs.pydantic.dev/concepts/models/#basic-model-usage)
Error Message
Signature-only (no traceback captured)
Error Message
-------------
- [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
- [ ] [Data validation/parsing](https://docs.pydantic.dev/concepts/models/#basic-model-usage)
Minimal Reproduction
import copy
from pydantic import BaseModel
class MyModel(BaseModel):
name: str
color: str
a = MyModel(name="a", color="blue")
b = copy.replace(a, color="red')
print(a)
# MyModel(name='a', color='blue')
print(b)
# MyModel(name='a', color='red')
Environment
- Python: 3.13
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.19
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pydantic/pydantic/pull/10596
First fixed release: 1.10.19
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
Version Compatibility Table
| Version | Status |
|---|---|
| 1.10.19 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.