mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
bpo-40170: PyType_SUPPORTS_WEAKREFS() becomes a regular function (GH-30938)
Convert the PyType_SUPPORTS_WEAKREFS() macro to a regular function. It no longer access the PyTypeObject.tp_weaklistoffset member directly. Add _PyType_SUPPORTS_WEAKREFS() static inline functions, used internally by Python for best performance.
This commit is contained in:
parent
f0a648152f
commit
af32b3ef1f
7 changed files with 24 additions and 10 deletions
|
|
@ -299,7 +299,7 @@ weakref___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
|||
PyWeakReference *ref, *proxy;
|
||||
PyWeakReference **list;
|
||||
|
||||
if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
|
||||
if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"cannot create weak reference to '%s' object",
|
||||
Py_TYPE(ob)->tp_name);
|
||||
|
|
@ -794,7 +794,7 @@ PyWeakref_NewRef(PyObject *ob, PyObject *callback)
|
|||
PyWeakReference **list;
|
||||
PyWeakReference *ref, *proxy;
|
||||
|
||||
if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
|
||||
if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"cannot create weak reference to '%s' object",
|
||||
Py_TYPE(ob)->tp_name);
|
||||
|
|
@ -853,7 +853,7 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
|
|||
PyWeakReference **list;
|
||||
PyWeakReference *ref, *proxy;
|
||||
|
||||
if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
|
||||
if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"cannot create weak reference to '%s' object",
|
||||
Py_TYPE(ob)->tp_name);
|
||||
|
|
@ -949,7 +949,7 @@ PyObject_ClearWeakRefs(PyObject *object)
|
|||
PyWeakReference **list;
|
||||
|
||||
if (object == NULL
|
||||
|| !PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))
|
||||
|| !_PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))
|
||||
|| Py_REFCNT(object) != 0)
|
||||
{
|
||||
PyErr_BadInternalCall();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue