File: refcount-demo.c
Function: refcount_demo
Error: ob_refcnt of PyListObject is 1 too high
22 PyObject *
23 refcount_demo(PyObject *self, PyObject *args)
24 {
25     PyObject *list;
26     PyObject *item;
27     list = PyList_New(1);
PyList_New() succeeds
PyListObject allocated at:     list = PyList_New(1);
28     if (!list)
taking False path
29         return NULL;
30 
31     item = PyLong_FromLong(42);
PyLong_FromLong() fails
32     if (!item)
taking True path
33         return NULL;
34 
35     PyList_SetItem(list, 0, item);
36     return list;
37 }
ob_refcnt of PyListObject is 1 too high