The Fix
pip install pydantic==2.8.0
Based on closed pydantic/pydantic issue #9780 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -256,7 +256,7 @@ def eval_type_backport(
"""
try:
- if sys.version_info >= (3, 12):
+ if sys.version_info >= (3, 13):
return typing._eval_type( # type: ignore
from pydantic import BaseModel
class SimpleModel(BaseModel):
s: str
Re-run: python fail.py
Option A — Upgrade to fixed release\npip install pydantic==2.8.0\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: $ python fail.py
- Mechanism: Fixes the Python version check for `_eval_type` to ensure compatibility with Python 3.12.3.
- Why the fix works: Fixes the Python version check for `_eval_type` to ensure compatibility with Python 3.12.3. (first fixed release: 2.8.0).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Shows up under Python 3.12.3 in real deployments (not just unit tests).
- Surfaces as: $ python fail.py
Proof / Evidence
- GitHub issue: #9780
- Fix PR: https://github.com/pydantic/pydantic/pull/9781
- First fixed release: 2.8.0
- 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.30
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@natehardison, Thanks for catching that. Working on a fix now! Looks like we had a >= 3.12 check instead of a 3.13 check...”
“@natehardison, Sure thing! We'll have v2.8 out on Monday with this fix, but you should be able to pull from main and get things working…”
“If a decent number of folks seem to be running into this with the beta, I can also do a v2.8.0b2. Let's just see in…”
Failure Signature (Search String)
- $ python fail.py
Error Message
Stack trace
Error Message
-------------
$ python fail.py
Traceback (most recent call last):
File "/Users/nateh/fail.py", line 4, in <module>
class SimpleModel(BaseModel):
File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 200, in __new__
set_model_fields(cls, bases, config_wrapper, types_namespace)
File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 469, in set_model_fields
fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_fields.py", line 132, in collect_model_fields
type_hints = get_cls_type_hints_lenient(cls, types_namespace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_typing_extra.py", line 228, in get_cls_type_hints_lenient
hints[name] = eval_type_lenient(value, globalns, localns)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_typing_extra.py", line 240, in eval_type_lenient
return eval_type_backport(value, globalns, localns)
^^^^^^^^^^^
... (truncated) ...
Minimal Reproduction
from pydantic import BaseModel
class SimpleModel(BaseModel):
s: str
Environment
- Python: 3.12.3
- Pydantic: 2.8.0
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.8.0
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/9781
First fixed release: 2.8.0
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: python fail.py
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 |
|---|---|
| 2.8.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.