summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2013-04-02 01:50:31 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2013-04-02 01:50:31 +0100
commit7328aaf0fbc8a5abdea2f30f875e904135743398 (patch)
tree6b7fb85fb3c3accf2efd6f711a42407b85a356f2
parent5aafe38fd74ea8468fbae3fccae69fc7aa3bd060 (diff)
downloadpsycopg2-7328aaf0fbc8a5abdea2f30f875e904135743398.tar.gz
Dropped GC support from Xid and Notify types
These types are immutable and have only atomic types attributes, so it's impossible to build loops out of them.
-rw-r--r--psycopg/notify_type.c17
-rw-r--r--psycopg/xid_type.c23
2 files changed, 9 insertions, 31 deletions
diff --git a/psycopg/notify_type.c b/psycopg/notify_type.c
index 973ee16..e2589a6 100644
--- a/psycopg/notify_type.c
+++ b/psycopg/notify_type.c
@@ -79,30 +79,18 @@ notify_init(notifyObject *self, PyObject *args, PyObject *kwargs)
payload = Text_FromUTF8("");
}
- Py_CLEAR(self->pid);
Py_INCREF(pid);
self->pid = pid;
- Py_CLEAR(self->channel);
Py_INCREF(channel);
self->channel = channel;
- Py_CLEAR(self->payload);
Py_INCREF(payload);
self->payload = payload;
return 0;
}
-static int
-notify_traverse(notifyObject *self, visitproc visit, void *arg)
-{
- Py_VISIT(self->pid);
- Py_VISIT(self->channel);
- Py_VISIT(self->payload);
- return 0;
-}
-
static void
notify_dealloc(notifyObject *self)
{
@@ -286,9 +274,10 @@ PyTypeObject notifyType = {
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+ /* Notify is not GC as it only has string attributes */
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
notify_doc, /*tp_doc*/
- (traverseproc)notify_traverse, /*tp_traverse*/
+ 0, /*tp_traverse*/
0, /*tp_clear*/
(richcmpfunc)notify_richcompare, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
diff --git a/psycopg/xid_type.c b/psycopg/xid_type.c
index 67ea011..ab6c33e 100644
--- a/psycopg/xid_type.c
+++ b/psycopg/xid_type.c
@@ -131,9 +131,9 @@ xid_init(xidObject *self, PyObject *args, PyObject *kwargs)
}
}
- self->format_id = PyInt_FromLong(format_id);
- self->gtrid = Text_FromUTF8(gtrid);
- self->bqual = Text_FromUTF8(bqual);
+ if (!(self->format_id = PyInt_FromLong(format_id))) { return -1; }
+ if (!(self->gtrid = Text_FromUTF8(gtrid))) { return -1; }
+ if (!(self->bqual = Text_FromUTF8(bqual))) { return -1; }
Py_INCREF(Py_None); self->prepared = Py_None;
Py_INCREF(Py_None); self->owner = Py_None;
Py_INCREF(Py_None); self->database = Py_None;
@@ -141,18 +141,6 @@ xid_init(xidObject *self, PyObject *args, PyObject *kwargs)
return 0;
}
-static int
-xid_traverse(xidObject *self, visitproc visit, void *arg)
-{
- Py_VISIT(self->format_id);
- Py_VISIT(self->gtrid);
- Py_VISIT(self->bqual);
- Py_VISIT(self->prepared);
- Py_VISIT(self->owner);
- Py_VISIT(self->database);
- return 0;
-}
-
static void
xid_dealloc(xidObject *self)
{
@@ -295,9 +283,10 @@ PyTypeObject xidType = {
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+ /* Notify is not GC as it only has string attributes */
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
xid_doc, /*tp_doc*/
- (traverseproc)xid_traverse, /*tp_traverse*/
+ 0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/