summaryrefslogtreecommitdiff
path: root/psycopg/adapter_datetime.c
diff options
context:
space:
mode:
Diffstat (limited to 'psycopg/adapter_datetime.c')
-rw-r--r--psycopg/adapter_datetime.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c
index 8d5aa3d..5f7327b 100644
--- a/psycopg/adapter_datetime.c
+++ b/psycopg/adapter_datetime.c
@@ -56,6 +56,8 @@ extern HIDDEN PyObject *pyPsycopgTzLOCAL;
static PyObject *
pydatetime_str(pydatetimeObject *self)
{
+ PyObject *res = NULL;
+ PyObject *iso;
if (self->type <= PSYCO_DATETIME_TIMESTAMP) {
PyObject *tz;
@@ -76,8 +78,7 @@ pydatetime_str(pydatetimeObject *self)
break;
}
- PyObject *res = NULL;
- PyObject *iso = PyObject_CallMethod(self->wrapped, "isoformat", NULL);
+ iso = PyObject_CallMethod(self->wrapped, "isoformat", NULL);
if (iso) {
res = PyString_FromFormat(fmt, PyString_AsString(iso));
Py_DECREF(iso);