summaryrefslogtreecommitdiffstats
path: root/Include/cpython/weakrefobject.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/cpython/weakrefobject.h')
-rw-r--r--Include/cpython/weakrefobject.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/Include/cpython/weakrefobject.h b/Include/cpython/weakrefobject.h
index 28acf72..9aa1a92 100644
--- a/Include/cpython/weakrefobject.h
+++ b/Include/cpython/weakrefobject.h
@@ -42,13 +42,13 @@ struct _PyWeakReference {
PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
+#define _PyWeakref_CAST(op) \
+ (assert(PyWeakref_Check(op)), _Py_CAST(PyWeakReference*, (op)))
+
Py_DEPRECATED(3.13) static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj)
{
- PyWeakReference *ref;
- PyObject *obj;
- assert(PyWeakref_Check(ref_obj));
- ref = _Py_CAST(PyWeakReference*, ref_obj);
- obj = ref->wr_object;
+ PyWeakReference *ref = _PyWeakref_CAST(ref_obj);
+ PyObject *obj = ref->wr_object;
// Explanation for the Py_REFCNT() check: when a weakref's target is part
// of a long chain of deallocations which triggers the trashcan mechanism,
// clearing the weakrefs can be delayed long after the target's refcount