summaryrefslogtreecommitdiff
path: root/psycopg/adapter_datetime.c
diff options
context:
space:
mode:
authorJames Henstridge <james@jamesh.id.au>2008-07-21 13:41:54 +0800
committerJames Henstridge <james@jamesh.id.au>2008-07-21 13:41:54 +0800
commit2273b79be912ab46e58418b077d50d59d5e4511c (patch)
tree931b85fc6b7397924ca4defa0ff9e5b432b428f2 /psycopg/adapter_datetime.c
parente0287c0db4ceb3daca64b2e3dd32397b357b7e3c (diff)
downloadpsycopg2-2273b79be912ab46e58418b077d50d59d5e4511c.tar.gz
Use Py_CLEAR() in a few more places, and do INCREF's before setting
struct members rather than afterwards.
Diffstat (limited to 'psycopg/adapter_datetime.c')
-rw-r--r--psycopg/adapter_datetime.c4
1 files changed, 2 insertions, 2 deletions
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);