* psycopg/adapter_asis.c (asis_traverse): add cyclic GC traversal

for AsIs adapters.
This commit is contained in:
James Henstridge 2008-07-01 09:57:16 +08:00
parent fd538a8b17
commit 47d2414e32
2 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,8 @@
2008-07-01 James Henstridge <james@jamesh.id.au>
* psycopg/adapter_asis.c (asis_traverse): add cyclic GC traversal
for AsIs adapters.
* psycopg/adapter_list.c (list_traverse): add cyclic GC traversal
for list adapters.

View File

@ -106,6 +106,13 @@ asis_setup(asisObject *self, PyObject *obj)
return 0;
}
static int
asis_traverse(asisObject *self, visitproc visit, void *arg)
{
Py_VISIT(self->wrapped);
return 0;
}
static void
asis_dealloc(PyObject* obj)
{
@ -141,7 +148,7 @@ asis_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static void
asis_del(PyObject* self)
{
PyObject_Del(self);
PyObject_GC_Del(self);
}
static PyObject *
@ -183,10 +190,10 @@ PyTypeObject asisType = {
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*/
asisType_doc, /*tp_doc*/
0, /*tp_traverse*/
(traverseproc)asis_traverse, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/