-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Expand file tree
/
Copy pathweakref.c
More file actions
34 lines (29 loc) · 684 Bytes
/
weakref.c
File metadata and controls
34 lines (29 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "parts.h"
#include "util.h"
static PyObject *
pyweakref_getref(PyObject *module, PyObject *ref)
{
NULLABLE(ref);
PyObject *obj = UNINITIALIZED_PTR;
int rc = PyWeakref_GetRef(ref, &obj);
if (rc == -1 && PyErr_Occurred()) {
assert(obj == NULL);
return NULL;
}
if (obj == NULL) {
return Py_BuildValue("i", rc);
}
else {
assert(obj != UNINITIALIZED_PTR);
return Py_BuildValue("iN", rc, obj);
}
}
static PyMethodDef test_methods[] = {
{"pyweakref_getref", pyweakref_getref, METH_O},
{NULL},
};
int
_PyTestCapi_Init_Weakref(PyObject *m)
{
return PyModule_AddFunctions(m, test_methods);
}