mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-39573: Use Py_REFCNT() macro (GH-18388)
Replace direct acccess to PyObject.ob_refcnt with usage of the Py_REFCNT() macro.
This commit is contained in:
parent
446463f8db
commit
a93c51e3a8
9 changed files with 42 additions and 38 deletions
|
|
@ -952,7 +952,8 @@ PyObject_ClearWeakRefs(PyObject *object)
|
|||
|
||||
if (object == NULL
|
||||
|| !PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))
|
||||
|| object->ob_refcnt != 0) {
|
||||
|| Py_REFCNT(object) != 0)
|
||||
{
|
||||
PyErr_BadInternalCall();
|
||||
return;
|
||||
}
|
||||
|
|
@ -975,8 +976,9 @@ PyObject_ClearWeakRefs(PyObject *object)
|
|||
current->wr_callback = NULL;
|
||||
clear_weakref(current);
|
||||
if (callback != NULL) {
|
||||
if (((PyObject *)current)->ob_refcnt > 0)
|
||||
if (Py_REFCNT((PyObject *)current) > 0) {
|
||||
handle_callback(current, callback);
|
||||
}
|
||||
Py_DECREF(callback);
|
||||
}
|
||||
}
|
||||
|
|
@ -993,8 +995,7 @@ PyObject_ClearWeakRefs(PyObject *object)
|
|||
for (i = 0; i < count; ++i) {
|
||||
PyWeakReference *next = current->wr_next;
|
||||
|
||||
if (((PyObject *)current)->ob_refcnt > 0)
|
||||
{
|
||||
if (Py_REFCNT((PyObject *)current) > 0) {
|
||||
Py_INCREF(current);
|
||||
PyTuple_SET_ITEM(tuple, i * 2, (PyObject *) current);
|
||||
PyTuple_SET_ITEM(tuple, i * 2 + 1, current->wr_callback);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue