mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-105927: Add PyWeakref_GetRef() function (#105932)
Add tests on PyWeakref_NewRef(), PyWeakref_GetObject(), PyWeakref_GET_OBJECT() and PyWeakref_GetRef().
This commit is contained in:
parent
4d140e5e06
commit
9c44656feb
11 changed files with 133 additions and 8 deletions
|
|
@ -894,6 +894,24 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
PyWeakref_GetRef(PyObject *ref, PyObject **pobj)
|
||||
{
|
||||
if (ref == NULL) {
|
||||
*pobj = NULL;
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
if (!PyWeakref_Check(ref)) {
|
||||
*pobj = NULL;
|
||||
PyErr_SetString(PyExc_TypeError, "expected a weakref");
|
||||
return -1;
|
||||
}
|
||||
*pobj = _PyWeakref_GET_REF(ref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
PyObject *
|
||||
PyWeakref_GetObject(PyObject *ref)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue