summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--psycopg/adapter_asis.c4
-rw-r--r--psycopg/adapter_binary.c8
-rw-r--r--psycopg/adapter_datetime.c4
-rw-r--r--psycopg/adapter_list.c10
-rw-r--r--psycopg/adapter_mxdatetime.c4
-rw-r--r--psycopg/adapter_pboolean.c4
-rw-r--r--psycopg/adapter_qstring.c12
-rw-r--r--psycopg/cursor_type.c2
8 files changed, 24 insertions, 24 deletions
diff --git a/psycopg/adapter_asis.c b/psycopg/adapter_asis.c
index 3fc9c56..2ad6ef5 100644
--- a/psycopg/adapter_asis.c
+++ b/psycopg/adapter_asis.c
@@ -96,8 +96,8 @@ asis_setup(asisObject *self, PyObject *obj)
self, ((PyObject *)self)->ob_refcnt
);
+ Py_INCREF(obj);
self->wrapped = obj;
- Py_INCREF(self->wrapped);
Dprintf("asis_setup: good asis object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
@@ -118,7 +118,7 @@ asis_dealloc(PyObject* obj)
{
asisObject *self = (asisObject *)obj;
- Py_XDECREF(self->wrapped);
+ Py_CLEAR(self->wrapped);
Dprintf("asis_dealloc: deleted asis object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c
index 205a5e2..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,
@@ -282,9 +282,9 @@ 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,
diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c
index 322e019..bf337ee 100644
--- a/psycopg/adapter_datetime.c
+++ b/psycopg/adapter_datetime.c
@@ -131,8 +131,8 @@ pydatetime_setup(pydatetimeObject *self, PyObject *obj, int type)
self, ((PyObject *)self)->ob_refcnt);
self->type = type;
+ Py_INCREF(obj);
self->wrapped = obj;
- Py_INCREF(self->wrapped);
Dprintf("pydatetime_setup: good pydatetime object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
@@ -154,7 +154,7 @@ pydatetime_dealloc(PyObject* obj)
{
pydatetimeObject *self = (pydatetimeObject *)obj;
- Py_XDECREF(self->wrapped);
+ Py_CLEAR(self->wrapped);
Dprintf("mpydatetime_dealloc: deleted pydatetime object at %p, "
"refcnt = " FORMAT_CODE_PY_SSIZE_T, obj, obj->ob_refcnt);
diff --git a/psycopg/adapter_list.c b/psycopg/adapter_list.c
index a1a9f59..2d26c39 100644
--- a/psycopg/adapter_list.c
+++ b/psycopg/adapter_list.c
@@ -108,9 +108,9 @@ list_prepare(listObject *self, PyObject *args)
reference to it; we'll need it during the recursive adapt() call (the
encoding is here for a future expansion that will make .getquoted()
work even without a connection to the backend. */
- Py_XDECREF(self->connection);
+ Py_CLEAR(self->connection);
+ Py_INCREF(conn);
self->connection = (PyObject*)conn;
- Py_INCREF(self->connection);
Py_INCREF(Py_None);
return Py_None;
@@ -169,8 +169,8 @@ list_setup(listObject *self, PyObject *obj, const char *enc)
if (enc) self->encoding = strdup(enc);
self->connection = NULL;
+ Py_INCREF(obj);
self->wrapped = obj;
- Py_INCREF(self->wrapped);
Dprintf("list_setup: good list object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
@@ -194,8 +194,8 @@ list_dealloc(PyObject* obj)
{
listObject *self = (listObject *)obj;
- Py_XDECREF(self->wrapped);
- Py_XDECREF(self->connection);
+ Py_CLEAR(self->wrapped);
+ Py_CLEAR(self->connection);
if (self->encoding) free(self->encoding);
Dprintf("list_dealloc: deleted list object at %p, "
diff --git a/psycopg/adapter_mxdatetime.c b/psycopg/adapter_mxdatetime.c
index 8750b1b..92b2181 100644
--- a/psycopg/adapter_mxdatetime.c
+++ b/psycopg/adapter_mxdatetime.c
@@ -152,8 +152,8 @@ mxdatetime_setup(mxdatetimeObject *self, PyObject *obj, int type)
);
self->type = type;
+ Py_INCREF(obj);
self->wrapped = obj;
- Py_INCREF(self->wrapped);
Dprintf("mxdatetime_setup: good mxdatetime object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
@@ -176,7 +176,7 @@ mxdatetime_dealloc(PyObject* obj)
{
mxdatetimeObject *self = (mxdatetimeObject *)obj;
- Py_XDECREF(self->wrapped);
+ Py_CLEAR(self->wrapped);
Dprintf("mxdatetime_dealloc: deleted mxdatetime object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
diff --git a/psycopg/adapter_pboolean.c b/psycopg/adapter_pboolean.c
index 29e3410..1ce80dd 100644
--- a/psycopg/adapter_pboolean.c
+++ b/psycopg/adapter_pboolean.c
@@ -106,8 +106,8 @@ pboolean_setup(pbooleanObject *self, PyObject *obj)
self, ((PyObject *)self)->ob_refcnt
);
+ Py_INCREF(obj);
self->wrapped = obj;
- Py_INCREF(self->wrapped);
Dprintf("pboolean_setup: good pboolean object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
@@ -130,7 +130,7 @@ pboolean_dealloc(PyObject* obj)
{
pbooleanObject *self = (pbooleanObject *)obj;
- Py_XDECREF(self->wrapped);
+ Py_CLEAR(self->wrapped);
Dprintf("pboolean_dealloc: deleted pboolean object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c
index 32185fe..1fb510b 100644
--- a/psycopg/adapter_qstring.c
+++ b/psycopg/adapter_qstring.c
@@ -216,10 +216,10 @@ qstring_prepare(qstringObject *self, PyObject *args)
Dprintf("qstring_prepare: set encoding to %s", conn->encoding);
}
- Py_XDECREF(self->conn);
+ Py_CLEAR(self->conn);
if (conn) {
+ Py_INCREF(conn);
self->conn = (PyObject*)conn;
- Py_INCREF(self->conn);
}
Py_INCREF(Py_None);
@@ -280,8 +280,8 @@ qstring_setup(qstringObject *self, PyObject *str, const char *enc)
/* FIXME: remove this orrible strdup */
if (enc) self->encoding = strdup(enc);
+ Py_INCREF(str);
self->wrapped = str;
- Py_INCREF(self->wrapped);
Dprintf("qstring_setup: good qstring object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
@@ -306,9 +306,9 @@ qstring_dealloc(PyObject* obj)
{
qstringObject *self = (qstringObject *)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);
if (self->encoding) free(self->encoding);
diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c
index 1ff5b96..8000816 100644
--- a/psycopg/cursor_type.c
+++ b/psycopg/cursor_type.c
@@ -1688,7 +1688,7 @@ cursor_repr(cursorObject *self)
static int
cursor_traverse(cursorObject *self, visitproc visit, void *arg)
{
- Py_VISIT(self->conn);
+ Py_VISIT((PyObject *)self->conn);
Py_VISIT(self->description);
Py_VISIT(self->pgstatus);
Py_VISIT(self->casts);