Skip to content

Commit 8116dde

Browse files
Factor out _PyStaticType_GET_WEAKREFS_LISTPTR().
1 parent e012b8b commit 8116dde

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Include/internal/pycore_object.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ _PyObject_GET_WEAKREFS_LISTPTR(PyObject *op)
224224
((PyTypeObject *)op)->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
225225
static_builtin_state *state = _PyStaticType_GetState(
226226
(PyTypeObject *)op);
227-
return &state->tp_weaklist;
227+
return _PyStaticType_GET_WEAKREFS_LISTPTR(state);
228228
}
229229
Py_ssize_t offset = Py_TYPE(op)->tp_weaklistoffset;
230230
return (PyObject **)((char *)op + offset);

Include/internal/pycore_typeobject.h

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ typedef struct {
5252
PyObject *tp_weaklist;
5353
} static_builtin_state;
5454

55+
static inline PyObject **
56+
_PyStaticType_GET_WEAKREFS_LISTPTR(static_builtin_state *state)
57+
{
58+
assert(state != NULL);
59+
return &state->tp_weaklist;
60+
}
61+
5562
struct types_state {
5663
struct type_cache type_cache;
5764
size_t num_builtins_initialized;

0 commit comments

Comments
 (0)