Skip to content

Commit 574bd95

Browse files
committed
Try suggestion
1 parent e29f7a9 commit 574bd95

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/pybind11/detail/class.h

+4
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,12 @@ extern "C" inline int pybind11_clear(PyObject *self) {
543543
inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
544544
auto *type = &heap_type->ht_type;
545545
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
546+
#if PY_VERSION_HEX < 0x030B0000
546547
type->tp_dictoffset = type->tp_basicsize; // place dict at the end
547548
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
548552
type->tp_traverse = pybind11_traverse;
549553
type->tp_clear = pybind11_clear;
550554

0 commit comments

Comments
 (0)