* psycopg/adapter_list.c (list_traverse): add cyclic GC traversal

for list adapters.
This commit is contained in:
James Henstridge 2008-07-01 09:34:51 +08:00
parent 26693621ef
commit fd538a8b17
2 changed files with 18 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2008-07-01 James Henstridge <james@jamesh.id.au>
* psycopg/adapter_list.c (list_traverse): add cyclic GC traversal
for list adapters.
2008-05-28 James Henstridge <james@jamesh.id.au>
* psycopg/cursor_type.c (cursor_setup): incref before setting

View File

@ -179,6 +179,16 @@ list_setup(listObject *self, PyObject *obj, const char *enc)
return 0;
}
static int
list_traverse(PyObject *obj, visitproc visit, void *arg)
{
listObject *self = (listObject *)obj;
Py_VISIT(self->wrapped);
Py_VISIT(self->connection);
return 0;
}
static void
list_dealloc(PyObject* obj)
{
@ -215,7 +225,7 @@ list_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static void
list_del(PyObject* self)
{
PyObject_Del(self);
PyObject_GC_Del(self);
}
static PyObject *
@ -253,11 +263,11 @@ PyTypeObject listType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
listType_doc, /*tp_doc*/
0, /*tp_traverse*/
list_traverse, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/