gh-105927: Deprecate PyWeakref_GetObject() function (#106006)

Deprecate PyWeakref_GetObject() and PyWeakref_GET_OBJECT() functions.
This commit is contained in:
Victor Stinner
2023-06-26 12:10:53 +02:00
committed by GitHub
parent dac3d389e7
commit c075a1974b
7 changed files with 33 additions and 4 deletions

View File

@@ -923,7 +923,12 @@ PyWeakref_GetObject(PyObject *ref)
PyErr_BadInternalCall();
return NULL;
}
return PyWeakref_GET_OBJECT(ref);
PyObject *obj = _PyWeakref_GET_REF(ref);
if (obj == NULL) {
return Py_None;
}
Py_DECREF(obj);
return obj; // borrowed reference
}
/* Note that there's an inlined copy-paste of handle_callback() in gcmodule.c's