diff --git a/ChangeLog b/ChangeLog index e594ef27..f068d978 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-07-01 James Henstridge + * 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. diff --git a/psycopg/adapter_asis.c b/psycopg/adapter_asis.c index 0e64eb5d..3fc9c560 100644 --- a/psycopg/adapter_asis.c +++ b/psycopg/adapter_asis.c @@ -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*/