worked since the :c:type:`PyWeakReference` structure is opaque in the
limited C API.
(Contributed by Victor Stinner in :issue:`35134`.)
+
+* Remove the ``PyHeapType_GET_MEMBERS()`` macro. It was exposed in the
+ public C API by mistake, it must only be used by Python internally.
+ Use the ``PyTypeObject.tp_members`` member instead.
+ (Contributed by Victor Stinner in :issue:`40170`.)
/* here are optional user slots, followed by the members. */
} PyHeapTypeObject;
-/* access macro to the members which are floating "behind" the object */
-#define PyHeapType_GET_MEMBERS(etype) \
- ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize))
-
PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *);
PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyType_LookupId(PyTypeObject *, _Py_Identifier *);
PyMemberDef *mp;
n = Py_SIZE(type);
- mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
+ mp = _PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
for (i = 0; i < n; i++, mp++) {
if (mp->type == T_OBJECT_EX) {
char *addr = (char *)self + mp->offset;
PyMemberDef *mp;
n = Py_SIZE(type);
- mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
+ mp = _PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
for (i = 0; i < n; i++, mp++) {
if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) {
char *addr = (char *)self + mp->offset;
PyHeapTypeObject *et = (PyHeapTypeObject *)type;
Py_ssize_t slotoffset = ctx->base->tp_basicsize;
if (et->ht_slots != NULL) {
- PyMemberDef *mp = PyHeapType_GET_MEMBERS(et);
+ PyMemberDef *mp = _PyHeapType_GET_MEMBERS(et);
Py_ssize_t nslot = PyTuple_GET_SIZE(et->ht_slots);
for (Py_ssize_t i = 0; i < nslot; i++, mp++) {
mp->name = PyUnicode_AsUTF8(
type->tp_basicsize = slotoffset;
type->tp_itemsize = ctx->base->tp_itemsize;
- type->tp_members = PyHeapType_GET_MEMBERS(et);
+ type->tp_members = _PyHeapType_GET_MEMBERS(et);
return 0;
}
else if (slot->slot == Py_tp_members) {
/* Move the slots to the heap type itself */
size_t len = Py_TYPE(type)->tp_itemsize * nmembers;
- memcpy(PyHeapType_GET_MEMBERS(res), slot->pfunc, len);
- type->tp_members = PyHeapType_GET_MEMBERS(res);
+ memcpy(_PyHeapType_GET_MEMBERS(res), slot->pfunc, len);
+ type->tp_members = _PyHeapType_GET_MEMBERS(res);
}
else {
/* Copy other slots directly */