From e0287c0db4ceb3daca64b2e3dd32397b357b7e3c Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Fri, 18 Jul 2008 17:42:31 +0800 Subject: [PATCH] * psycopg/adapter_qstring.c (qstring_traverse): add cyclic GC traversal for quoted string adapters. * psycopg/adapter_pboolean.c (pboolean_traverse): add cyclic GC traversal for boolean adapters. * psycopg/adapter_mxdatetime.c (mxdatetime_traverse): add cyclic GC traversal for mxdatetime adapters. * psycopg/adapter_datetime.c (pydatetime_traverse): add cyclic GC traversal for datetime adapters. --- ChangeLog | 14 ++++++++++++++ psycopg/adapter_datetime.c | 15 ++++++++++++--- psycopg/adapter_mxdatetime.c | 15 ++++++++++++--- psycopg/adapter_pboolean.c | 15 ++++++++++++--- psycopg/adapter_qstring.c | 17 ++++++++++++++--- 5 files changed, 64 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 089950d0..024f2a17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-07-18 James Henstridge + + * psycopg/adapter_qstring.c (qstring_traverse): add cyclic GC + traversal for quoted string adapters. + + * psycopg/adapter_pboolean.c (pboolean_traverse): add cyclic GC + traversal for boolean adapters. + + * psycopg/adapter_mxdatetime.c (mxdatetime_traverse): add cyclic + GC traversal for mxdatetime adapters. + + * psycopg/adapter_datetime.c (pydatetime_traverse): add cyclic GC + traversal for datetime adapters. + 2008-07-01 James Henstridge * psycopg/adapter_binary.c (binary_traverse): add cyclic GC diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index e9fcc1e1..322e019d 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -140,6 +140,15 @@ pydatetime_setup(pydatetimeObject *self, PyObject *obj, int type) return 0; } +static int +pydatetime_traverse(PyObject *obj, visitproc visit, void *arg) +{ + pydatetimeObject *self = (pydatetimeObject *)obj; + + Py_VISIT(self->wrapped); + return 0; +} + static void pydatetime_dealloc(PyObject* obj) { @@ -174,7 +183,7 @@ pydatetime_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static void pydatetime_del(PyObject* self) { - PyObject_Del(self); + PyObject_GC_Del(self); } static PyObject * @@ -213,11 +222,11 @@ PyTypeObject pydatetimeType = { 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*/ pydatetimeType_doc, /*tp_doc*/ - 0, /*tp_traverse*/ + pydatetime_traverse, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ diff --git a/psycopg/adapter_mxdatetime.c b/psycopg/adapter_mxdatetime.c index 48ead92e..8750b1bf 100644 --- a/psycopg/adapter_mxdatetime.c +++ b/psycopg/adapter_mxdatetime.c @@ -162,6 +162,15 @@ mxdatetime_setup(mxdatetimeObject *self, PyObject *obj, int type) return 0; } +static int +mxdatetime_traverse(PyObject *obj, visitproc visit, void *arg) +{ + mxdatetimeObject *self = (mxdatetimeObject *)obj; + + Py_VISIT(self->wrapped); + return 0; +} + static void mxdatetime_dealloc(PyObject* obj) { @@ -198,7 +207,7 @@ mxdatetime_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static void mxdatetime_del(PyObject* self) { - PyObject_Del(self); + PyObject_GC_Del(self); } static PyObject * @@ -237,11 +246,11 @@ PyTypeObject mxdatetimeType = { 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*/ mxdatetimeType_doc, /*tp_doc*/ - 0, /*tp_traverse*/ + mxdatetime_traverse, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ diff --git a/psycopg/adapter_pboolean.c b/psycopg/adapter_pboolean.c index 05d1d046..29e3410e 100644 --- a/psycopg/adapter_pboolean.c +++ b/psycopg/adapter_pboolean.c @@ -116,6 +116,15 @@ pboolean_setup(pbooleanObject *self, PyObject *obj) return 0; } +static int +pboolean_traverse(PyObject *obj, visitproc visit, void *arg) +{ + pbooleanObject *self = (pbooleanObject *)obj; + + Py_VISIT(self->wrapped); + return 0; +} + static void pboolean_dealloc(PyObject* obj) { @@ -151,7 +160,7 @@ pboolean_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static void pboolean_del(PyObject* self) { - PyObject_Del(self); + PyObject_GC_Del(self); } static PyObject * @@ -194,10 +203,10 @@ PyTypeObject pbooleanType = { 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*/ pbooleanType_doc, /*tp_doc*/ - 0, /*tp_traverse*/ + pboolean_traverse, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 3684039b..32185fef 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -290,6 +290,17 @@ qstring_setup(qstringObject *self, PyObject *str, const char *enc) return 0; } +static int +qstring_traverse(PyObject *obj, visitproc visit, void *arg) +{ + qstringObject *self = (qstringObject *)obj; + + Py_VISIT(self->wrapped); + Py_VISIT(self->buffer); + Py_VISIT(self->conn); + return 0; +} + static void qstring_dealloc(PyObject* obj) { @@ -330,7 +341,7 @@ qstring_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static void qstring_del(PyObject* self) { - PyObject_Del(self); + PyObject_GC_Del(self); } static PyObject * @@ -369,11 +380,11 @@ PyTypeObject qstringType = { 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*/ qstringType_doc, /*tp_doc*/ - 0, /*tp_traverse*/ + qstring_traverse, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/