Skip to content

Commit fe87568

Browse files
PyPy 3.11 does not implement Py_TPFLAGS_MANAGED_DICT (#5508)
* PyPy 3.11 does not implement Py_TPFLAGS_MANAGED_DICT * add a comment (from review) * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 82845c3 commit fe87568

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/pybind11/detail/class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,9 @@ extern "C" inline int pybind11_clear(PyObject *self) {
574574
inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
575575
auto *type = &heap_type->ht_type;
576576
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
577-
#if PY_VERSION_HEX < 0x030B0000
578-
type->tp_dictoffset = type->tp_basicsize; // place dict at the end
579-
type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it
577+
#if PY_VERSION_HEX < 0x030B0000 || defined(PYPY_VERSION) // For PyPy see PR #5508
578+
type->tp_dictoffset = type->tp_basicsize; // place dict at the end
579+
type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it
580580
#else
581581
type->tp_flags |= Py_TPFLAGS_MANAGED_DICT;
582582
#endif

0 commit comments

Comments
 (0)