We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e29f7a9 commit 574bd95Copy full SHA for 574bd95
include/pybind11/detail/class.h
@@ -543,8 +543,12 @@ extern "C" inline int pybind11_clear(PyObject *self) {
543
inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
544
auto *type = &heap_type->ht_type;
545
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
546
+#if PY_VERSION_HEX < 0x030B0000
547
type->tp_dictoffset = type->tp_basicsize; // place dict at the end
548
type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it
549
+#else
550
+ type->tp_flags |= Py_TPFLAGS_MANAGED_DICT;
551
+#endif
552
type->tp_traverse = pybind11_traverse;
553
type->tp_clear = pybind11_clear;
554
0 commit comments