diff --git a/ChangeLog b/ChangeLog index 60018ff1..421e9e6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-03-17 Federico Di Gregorio + + * psycopg/adapter_datetime.c: fixed double decref when using + a PyObject as a parameter in a nested call (line 415). + 2008-03-17 James Henstridge * psycopg/typecast.c (typecast_parse_time): give the correct diff --git a/NEWS b/NEWS index c07f16cc..61cf125d 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -What's new in psycopg 2.0.7 (unreleased) +What's new in psycopg 2.0.7 --------------------------- * Improved error handling: @@ -43,7 +43,6 @@ What's new in psycopg 2.0.7 (unreleased) to set the PSYCOPG_DEBUG environment variable to turn on debug spew. - What's new in psycopg 2.0.6 --------------------------- diff --git a/ZPsycopgDA/DA.py b/ZPsycopgDA/DA.py index 5afa4294..a80f9fde 100644 --- a/ZPsycopgDA/DA.py +++ b/ZPsycopgDA/DA.py @@ -18,7 +18,7 @@ # See the LICENSE file for details. -ALLOWED_PSYCOPG_VERSIONS = ('2.0.6',) +ALLOWED_PSYCOPG_VERSIONS = ('2.0.7',) import sys import time diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index 98922d3c..1a68a678 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -406,17 +406,18 @@ psyco_TimestampFromTicks(PyObject *self, PyObject *args) t = (time_t)round(ticks); ticks -= (double)t; if (localtime_r(&t, &tm)) { - args = Py_BuildValue("iiiiidO", - tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, - tm.tm_hour, tm.tm_min, - (double)tm.tm_sec + ticks, - pyPsycopgTzLOCAL); - if (args) { -/* Dprintf("psyco_TimestampFromTicks: args->refcnt = %d", args->ob_refcnt);*/ - res = psyco_Timestamp(self, args); - Py_DECREF(args); + PyObject *value = Py_BuildValue("iiiiidO", + tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, + tm.tm_hour, tm.tm_min, + (double)tm.tm_sec + ticks, + pyPsycopgTzLOCAL); + if (value) { + /* we don't decref the value here because the call to + psyco_Timestamp will do that by calling PyArg_ParseTuple */ + res = psyco_Timestamp(self, value); } } + return res; } diff --git a/setup.py b/setup.py index 9dfc79b4..09181d4c 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ from distutils.command.build_ext import build_ext from distutils.sysconfig import get_python_inc from distutils.ccompiler import get_default_compiler -PSYCOPG_VERSION = '2.0.6' +PSYCOPG_VERSION = '2.0.7' version_flags = [] PLATFORM_IS_WINDOWS = sys.platform.lower().startswith('win')