$ the-wire · showcase
pydantic-core GC traversal and unpickling fixes land
By RepoJournal · Filed · About FastAPI & Pydantic · Composed from the cited sources · methodology
Pydantic's top three stories today all fix correctness bugs in pydantic-core's object graph handling and generic model serialization, while FastAPI corrects route metadata for included routes.
Fix various issues about GC tracking in `pydantic-core` pydantic/pydantic
Viicos stopped traversing InternalValidator.validator from the GC hooks of ValidatorCallable, AssignmentValidatorCallable and ValidatorIterator, since it is an Arc clone of a subtree the SchemaValidator already owns and traverses, so objects inside were visited twice per reference; the same fix applies to SerializationCallable.serializer and SerializationIterator.item_serializer. That double-vi...
Fix unpickling of generic classes defined in separate module pydantic/pydantic
Unpickling a generic model class defined in a different module, a pattern common in a models.py split from your app package, previously failed; the fix resolves the class, but a generic whose forward reference depends on a module-level import performed later, as the PR shows with a circular import, no longer resolves.
Support explicit `by_alias` overriding `validate_by_alias` in validation JSON schemas pydantic/pydantic
An explicit by_alias passed to validation now overrides validate_by_alias when generating validation JSON schemas, so schema output matches the alias behavior you actually request rather than the model config default.
Honor `ser_json_inf_nan` in Python serialization with `mode=json` pydantic/pydantic
Python-side serialization with mode=json now honors ser_json_inf_nan, so inf and nan handling in JSON-mode dumps is governed by your model config instead of diverging from the schema path.
🐛 Fix included route metadata in `iter_route_contexts()` fastapi/fastapi
tiangolo fixed the route metadata reported by iter_route_contexts() for included routers, so anything reading that context gets the correct route information.