Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
# TODO: Enable this once fixed https://github.com/jcrist/msgspec/issues/910
# - "3.13"
- "3.13"
- "3.14"

steps:
Expand Down
4 changes: 4 additions & 0 deletions src/msgspec/_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5328,6 +5328,10 @@ Struct_alloc(PyTypeObject *type) {
PyObject *obj;
bool is_gc = MS_TYPE_IS_GC(type);

#if PY313_PLUS && !PY314_PLUS
type->tp_flags &= ~Py_TPFLAGS_INLINE_VALUES;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm almost certain you'll trigger assertion failures (or worse, get spurious crashes) with this. Supertypes don't expect their flags to be different in subtypes.

#endif

if (is_gc) {
obj = PyObject_GC_New(PyObject, type);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually calling PyObject_GC_New/PyObject_New doesn't really work for subtypes. It might work in practice sometimes, but it's not something that's supposed to be supported.

I believe the root of this bug comes from the fact that on 3.13, inline values are initialized in the tp_alloc slot of type objects, which is skipped here. In 3.14, we moved that logic to PyObject_GC_New because we decided to support more types.

So, to fix this, just call type->tp_alloc instead; that will invoke the supertype (PyType_GenericAlloc) and initialize the inline values.

}
Expand Down