diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-06 12:07:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 12:07:02 (GMT) |
commit | 38aefc585f60a77d66f4fbe5a37594a488b53474 (patch) | |
tree | 142fb1765e421b36ee746a6a5f53b0d52161b2c2 /Objects | |
parent | 08050e959e6c40839cd2c9e5f6a4fd1513e3d605 (diff) | |
download | cpython-38aefc585f60a77d66f4fbe5a37594a488b53474.zip cpython-38aefc585f60a77d66f4fbe5a37594a488b53474.tar.gz cpython-38aefc585f60a77d66f4fbe5a37594a488b53474.tar.bz2 |
bpo-40170: PyObject_GET_WEAKREFS_LISTPTR() becomes a function (GH-19377)
Convert the PyObject_GET_WEAKREFS_LISTPTR() macro to a function to
hide implementation details: the macro accessed directly to the
PyTypeObject.tp_weaklistoffset member.
Add _PyObject_GET_WEAKREFS_LISTPTR() static inline function to the
internal C API.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object.c | 8 | ||||
-rw-r--r-- | Objects/typeobject.c | 2 | ||||
-rw-r--r-- | Objects/weakrefobject.c | 3 |
3 files changed, 11 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c index e6d0da1..05241e8 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2206,6 +2206,14 @@ _Py_Dealloc(PyObject *op) (*dealloc)(op); } + +PyObject ** +PyObject_GET_WEAKREFS_LISTPTR(PyObject *op) +{ + return _PyObject_GET_WEAKREFS_LISTPTR(op); +} + + #ifdef __cplusplus } #endif diff --git a/Objects/typeobject.c b/Objects/typeobject.c index bed50d1..bdd16af 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1271,7 +1271,7 @@ subtype_dealloc(PyObject *self) if (type->tp_weaklistoffset && !base->tp_weaklistoffset) { /* Modeled after GET_WEAKREFS_LISTPTR() */ PyWeakReference **list = (PyWeakReference **) \ - PyObject_GET_WEAKREFS_LISTPTR(self); + _PyObject_GET_WEAKREFS_LISTPTR(self); while (*list) _PyWeakref_ClearRef(*list); } diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 7a5d9fb..1e6697b 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -1,9 +1,10 @@ #include "Python.h" +#include "pycore_object.h" // _PyObject_GET_WEAKREFS_LISTPTR #include "structmember.h" #define GET_WEAKREFS_LISTPTR(o) \ - ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) + ((PyWeakReference **) _PyObject_GET_WEAKREFS_LISTPTR(o)) Py_ssize_t |