Skip to content

Commit 53c7901

Browse files
Factor out _PyObject_GET_BASIC_WEAKREFS_LISTPTR().
1 parent 3e7cad3 commit 53c7901

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Include/internal/pycore_object.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ extern void _Py_PrintReferences(FILE *);
217217
extern void _Py_PrintReferenceAddresses(FILE *);
218218
#endif
219219

220+
static inline PyObject **
221+
_PyObject_GET_BASIC_WEAKREFS_LISTPTR(PyObject *op)
222+
{
223+
Py_ssize_t offset = Py_TYPE(op)->tp_weaklistoffset;
224+
return (PyObject **)((char *)op + offset);
225+
}
226+
220227
static inline PyObject **
221228
_PyObject_GET_WEAKREFS_LISTPTR(PyObject *op)
222229
{
@@ -226,8 +233,7 @@ _PyObject_GET_WEAKREFS_LISTPTR(PyObject *op)
226233
(PyTypeObject *)op);
227234
return _PyStaticType_GET_WEAKREFS_LISTPTR(state);
228235
}
229-
Py_ssize_t offset = Py_TYPE(op)->tp_weaklistoffset;
230-
return (PyObject **)((char *)op + offset);
236+
return _PyObject_GET_BASIC_WEAKREFS_LISTPTR(op);
231237
}
232238

233239
// Fast inlined version of PyObject_IS_GC()

Objects/typeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ subtype_dealloc(PyObject *self)
15091509
if (type->tp_weaklistoffset && !base->tp_weaklistoffset) {
15101510
/* Modeled after GET_WEAKREFS_LISTPTR() */
15111511
PyWeakReference **list = (PyWeakReference **) \
1512-
_PyObject_GET_WEAKREFS_LISTPTR(self);
1512+
_PyObject_GET_BASIC_WEAKREFS_LISTPTR(self);
15131513
while (*list)
15141514
_PyWeakref_ClearRef(*list);
15151515
}

0 commit comments

Comments
 (0)