The Fix
pip install pydantic==1.10.1
Based on closed pydantic/pydantic issue #8683 · PR/commit linked
@@ -7,7 +7,7 @@ isort==4.3.21
pycodestyle==2.5.0
pyflakes==2.1.1
-pytest==5.3.4
+pytest==5.3.5
pytest-cov==2.8.1
import datetime
from pydantic import BaseModel
class Event(BaseModel):
dt: datetime.datetime = None
event = Event(dt="2024-01-01T13:56:57.115Z")
print("This should be True:", event.dt.tzinfo == datetime.UTC)
# prints: This should be True: False
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.1\nWhen NOT to use: This fix should not be applied if relying on custom timezone comparisons.\n\n
Why This Fix Works in Production
- Trigger: A Pydantic model with a `datetime.datetime` attribute and initialized with an UTC timestamp fails to correctly compare its `.tzinfo` attribute to…
- Mechanism: Addresses the issue of incorrect comparison of Pydantic's TzInfo with datetime.UTC by implementing necessary equality checks.
- Why the fix works: Addresses the issue of incorrect comparison of Pydantic's TzInfo with datetime.UTC by implementing necessary equality checks. (first fixed release: 1.10.1).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- Shows up under Python 3.11 in real deployments (not just unit tests).
- Production symptom (often without a traceback): A Pydantic model with a `datetime.datetime` attribute and initialized with an UTC timestamp fails to correctly compare its `.tzinfo` attribute to `datetime.UTC` for equality.
Proof / Evidence
- GitHub issue: #8683
- Fix PR: https://github.com/pydantic/pydantic-core/pull/1197
- First fixed release: 1.10.1
- 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.61
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@gkoller, Thanks for reporting this”
“don't we just need to fix TzInfo::__richcmp__?”
“We could definitely implement comparisons for pydantic_core.TzInfo with fixed-offset datetime.timezone, which I think would fix the UTC case”
“Note that Python’s own standard library has many different UTC zone objects: for example, datetime.UTC, zoneinfo.ZoneInfo("UCT"), zoneinfo.ZoneInfo("UTC"), zoneinfo.ZoneInfo("Universal"), zoneinfo.ZoneInfo("Zulu"), zoneinfo.ZoneInfo("Etc/UCT"), zoneinfo.ZoneIn”
Failure Signature (Search String)
- A Pydantic model with a `datetime.datetime` attribute and initialized with an UTC timestamp fails to correctly compare its `.tzinfo` attribute to `datetime.UTC` for equality.
- Though It is a change in behaviour from Pydantic V1 to V2 and probably should be documented as such somewhere in the [Migration Guide](https://docs.pydantic.dev/latest/migration).
Copy-friendly signature
Failure Signature
-----------------
A Pydantic model with a `datetime.datetime` attribute and initialized with an UTC timestamp fails to correctly compare its `.tzinfo` attribute to `datetime.UTC` for equality.
Though It is a change in behaviour from Pydantic V1 to V2 and probably should be documented as such somewhere in the [Migration Guide](https://docs.pydantic.dev/latest/migration).
Error Message
Signature-only (no traceback captured)
Error Message
-------------
A Pydantic model with a `datetime.datetime` attribute and initialized with an UTC timestamp fails to correctly compare its `.tzinfo` attribute to `datetime.UTC` for equality.
Though It is a change in behaviour from Pydantic V1 to V2 and probably should be documented as such somewhere in the [Migration Guide](https://docs.pydantic.dev/latest/migration).
Minimal Reproduction
import datetime
from pydantic import BaseModel
class Event(BaseModel):
dt: datetime.datetime = None
event = Event(dt="2024-01-01T13:56:57.115Z")
print("This should be True:", event.dt.tzinfo == datetime.UTC)
# prints: This should be True: False
Environment
- Python: 3.11
- Pydantic: 2
What Broke
Comparisons of datetime objects with UTC timestamps fail, leading to incorrect behavior.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.1
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pydantic/pydantic-core/pull/1197
First fixed release: 1.10.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if relying on custom timezone comparisons.
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.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.