Description
Bug report
Checklist
- I am confident this is a bug in CPython, not a bug in a third-party project
- I have searched the CPython issue tracker,
and am confident this bug has not been reported before
CPython versions tested on:
3.11, 3.12
Operating systems tested on:
Windows
Output from running 'python -VV' on the command line:
No response
A clear and concise description of the bug:
Background: I am working on a Python C Extension that creates new types using PyType_FromMetaclass
(PyType_FromModuleAndSpec
in Python < 3.12) and ran into an assertions error at
Line 1214 in 63bcd91
So I fired up the debugger to find out where tp_dictoffset
is getting set to -1 (my extension isn't doing anything explicitly with this). I found the culprit at
Line 6944 in 63bcd91
This type inherits from another C extension type and a type implemented in Python. The type implemented in Python has tp_dictoffset
set to -1 and it is being copied to the new type.
In other cases in the file where tp_dictoffset
is explicitly set to -1, Py_TPFLAGS_MANAGED_DICT
is also set. This fact combined with the the fact that other slot assignments in inherit_slots()
also set flags when needed make me thing that perhaps this one was overlooked?