jcrist / msgspec

A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
https://jcristharif.com/msgspec/
BSD 3-Clause "New" or "Revised" License
2.43k stars 75 forks source link

Use `PyType_GetDict` in Python 3.12+ #745

Closed jcrist closed 1 month ago

jcrist commented 1 month ago

Previously we were incorrectly accessing tp_dict in mixin classes when defining a Struct class on Python 3.12+. This could result in a segfault if a user tried to create a Struct class that also subclassed from an interpreter builtin type (like Exception). Now we error nicely instead.

Fixes #727.