Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4efdb41

Browse files
committed
Test Py_IncRef() and Py_DecRef() C functions
1 parent 72f455e commit 4efdb41

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Modules/_testcapimodule.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,6 +2613,16 @@ test_decref_doesnt_leak(PyObject *ob)
26132613
Py_RETURN_NONE;
26142614
}
26152615

2616+
static PyObject *
2617+
test_incref_decref_API(PyObject *ob)
2618+
{
2619+
PyObject *obj = PyLong_FromLong(0);
2620+
Py_IncRef(ob);
2621+
Py_DecRef(obj);
2622+
Py_DecRef(obj);
2623+
Py_RETURN_NONE;
2624+
}
2625+
26162626
static PyObject *
26172627
test_pymem_alloc0(PyObject *self)
26182628
{
@@ -2781,6 +2791,7 @@ static PyMethodDef TestMethods[] = {
27812791
{"test_incref_doesnt_leak", (PyCFunction)test_incref_doesnt_leak, METH_NOARGS},
27822792
{"test_xdecref_doesnt_leak",(PyCFunction)test_xdecref_doesnt_leak, METH_NOARGS},
27832793
{"test_decref_doesnt_leak", (PyCFunction)test_decref_doesnt_leak, METH_NOARGS},
2794+
{"test_incref_decref_API", (PyCFunction)test_incref_decref_API, METH_NOARGS},
27842795
{"test_long_and_overflow", (PyCFunction)test_long_and_overflow,
27852796
METH_NOARGS},
27862797
{"test_long_as_double", (PyCFunction)test_long_as_double,METH_NOARGS},

0 commit comments

Comments
 (0)