summaryrefslogtreecommitdiff
path: root/Objects/weakrefobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/weakrefobject.c')
-rw-r--r--Objects/weakrefobject.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index bf79e0c7ec..d104b646f0 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -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);