From d13be6411e452b688b0e65a9c1b4a98cfc0bcd10 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Mon, 3 Feb 2025 05:14:17 +1100 Subject: [PATCH] PyPy 3.11 does not implement Py_TPFLAGS_MANAGED_DICT --- include/pybind11/detail/class.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h index f501467ded..e6a501699d 100644 --- a/include/pybind11/detail/class.h +++ b/include/pybind11/detail/class.h @@ -574,7 +574,7 @@ extern "C" inline int pybind11_clear(PyObject *self) { inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) { auto *type = &heap_type->ht_type; type->tp_flags |= Py_TPFLAGS_HAVE_GC; -#if PY_VERSION_HEX < 0x030B0000 +#if PY_VERSION_HEX < 0x030B0000 || defined(PYPY_VERSION) type->tp_dictoffset = type->tp_basicsize; // place dict at the end type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it #else