diff options
| author | Federico Di Gregorio <fog@initd.org> | 2008-07-26 15:10:02 +0200 |
|---|---|---|
| committer | Federico Di Gregorio <fog@initd.org> | 2008-07-26 15:10:02 +0200 |
| commit | ceee4c816fde88fa4ab32074b923bf4d31cd3598 (patch) | |
| tree | 6aefd58fd5d4e2565eeeb70c27938a8f5dfc3bf6 /psycopg/adapter_binary.c | |
| parent | e95a4d9d2ee995715f09431039360de6717e4738 (diff) | |
| parent | a2f3e4a3acd58afb09438be186e5fb0a98620820 (diff) | |
| download | psycopg2-ceee4c816fde88fa4ab32074b923bf4d31cd3598.tar.gz | |
Merge from jh
Diffstat (limited to 'psycopg/adapter_binary.c')
| -rw-r--r-- | psycopg/adapter_binary.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c index 1fb9d40..306c9e5 100644 --- a/psycopg/adapter_binary.c +++ b/psycopg/adapter_binary.c @@ -257,8 +257,8 @@ binary_setup(binaryObject *self, PyObject *str) self->buffer = NULL; self->conn = NULL; + Py_INCREF(str); self->wrapped = str; - Py_INCREF(self->wrapped); Dprintf("binary_setup: good binary object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, @@ -266,14 +266,25 @@ binary_setup(binaryObject *self, PyObject *str) return 0; } +static int +binary_traverse(PyObject *obj, visitproc visit, void *arg) +{ + binaryObject *self = (binaryObject *)obj; + + Py_VISIT(self->wrapped); + Py_VISIT(self->buffer); + Py_VISIT(self->conn); + return 0; +} + static void binary_dealloc(PyObject* obj) { binaryObject *self = (binaryObject *)obj; - Py_XDECREF(self->wrapped); - Py_XDECREF(self->buffer); - Py_XDECREF(self->conn); + Py_CLEAR(self->wrapped); + Py_CLEAR(self->buffer); + Py_CLEAR(self->conn); Dprintf("binary_dealloc: deleted binary object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, @@ -303,7 +314,7 @@ binary_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static void binary_del(PyObject* self) { - PyObject_Del(self); + PyObject_GC_Del(self); } static PyObject * @@ -341,11 +352,11 @@ PyTypeObject binaryType = { 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*/ binaryType_doc, /*tp_doc*/ - 0, /*tp_traverse*/ + binary_traverse, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ |
