You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are there any reasons why PyObject_GC_New doesn't do this initialization in Python 3.13?
I tried to fix msgspec by adding a call to the private function _PyObject_InitInlineValues, but this causes other problems.
Can you tell me how to fix this place more correctly? I just came up with the idea to make a copy of the _PyObject_InitInlineValues function in msgspec for Python 3.13.
I believe Py_TPFLAGS_INLINE_VALUES is supposed to be opt-in and only for a few special types in 3.13, so I'm a little bit confused about what msgspec is doing with the type. Are you inheriting from a type that uses inline values, but calling PyObject_GC_New instead of tp_new?
If so -- don't do that. You always have to call the tp_new slot when inheriting (to invoke the supertype), and risk running into breakages like this if you don't. I think we added the logic to initialize inline values in PyObject_GC_New because we wanted to support more types, but since that was a feature, we didn't backport that logic to 3.13.
Activity
picnixz commentedon Dec 13, 2025
I think it's because we considered this as a new feature and thus we didn't backport it to 3.13.
cc @markshannon
shadchin commentedon Dec 13, 2025
I succeeded in fixing
msgspecthis waytype->tp_flags &=~Py_TPFLAGS_INLINE_VALUES;ZeroIntensity commentedon Dec 15, 2025
I believe
Py_TPFLAGS_INLINE_VALUESis supposed to be opt-in and only for a few special types in 3.13, so I'm a little bit confused about what msgspec is doing with the type. Are you inheriting from a type that uses inline values, but callingPyObject_GC_Newinstead oftp_new?If so -- don't do that. You always have to call the
tp_newslot when inheriting (to invoke the supertype), and risk running into breakages like this if you don't. I think we added the logic to initialize inline values inPyObject_GC_Newbecause we wanted to support more types, but since that was a feature, we didn't backport that logic to 3.13.shadchin commentedon Dec 16, 2025
I'm not an msgspec developer, so I don't really understand how it works either :)
I updated Python to 3.13 and saw that test with msgspec was segfaulted. We have a static build, so I just added it for us:
Now I try to help msgspec fix this problem.
kumaraditya303 commentedon Dec 16, 2025
msgspecis incorrectly usingPyObject_GC_Newfor allocating the object, it should usePyType_GenericAllocwhich would initialize the inline values.ZeroIntensity commentedon Feb 2, 2026
This seems like it's a downstream problem.