From fd538a8b17e741c611ac0519b2e107cc4fd39fdb Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Tue, 1 Jul 2008 09:34:51 +0800 Subject: [PATCH] * psycopg/adapter_list.c (list_traverse): add cyclic GC traversal for list adapters. --- ChangeLog | 5 +++++ psycopg/adapter_list.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a58f1f6..e594ef27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-07-01 James Henstridge + + * psycopg/adapter_list.c (list_traverse): add cyclic GC traversal + for list adapters. + 2008-05-28 James Henstridge * psycopg/cursor_type.c (cursor_setup): incref before setting diff --git a/psycopg/adapter_list.c b/psycopg/adapter_list.c index b6022bd5..a1a9f598 100644 --- a/psycopg/adapter_list.c +++ b/psycopg/adapter_list.c @@ -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*/