Jump to solution
Verify

The Fix

pip install pydantic==1.10.19

Based on closed pydantic/pydantic issue #10573 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -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)
repro.py
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')
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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

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!”
@sydney-runkle · 2024-10-10 · source

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
signature.txt
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.txt
Error Message ------------- - [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/) - [ ] [Data validation/parsing](https://docs.pydantic.dev/concepts/models/#basic-model-usage)

Minimal Reproduction

repro.py
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

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

Verify Fix

verify
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

VersionStatus
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.