* 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.
This commit is contained in:
James Henstridge 2008-07-18 17:42:31 +08:00
parent 590542e973
commit e0287c0db4
5 changed files with 64 additions and 12 deletions

View File

@ -1,3 +1,17 @@
2008-07-18 James Henstridge <james@jamesh.id.au>
* 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 <james@jamesh.id.au>
* psycopg/adapter_binary.c (binary_traverse): add cyclic GC

View File

@ -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*/

View File

@ -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*/

View File

@ -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*/

View File

@ -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*/