Fixed test segfault due to double decref.

This commit is contained in:
Federico Di Gregorio 2008-03-17 08:13:16 +00:00
parent cceaa7331b
commit 8103f44a12
5 changed files with 18 additions and 13 deletions

View File

@ -1,3 +1,8 @@
2008-03-17 Federico Di Gregorio <fog@initd.org>
* 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 <james@jamesh.id.au> 2008-03-17 James Henstridge <james@jamesh.id.au>
* psycopg/typecast.c (typecast_parse_time): give the correct * psycopg/typecast.c (typecast_parse_time): give the correct

3
NEWS
View File

@ -1,4 +1,4 @@
What's new in psycopg 2.0.7 (unreleased) What's new in psycopg 2.0.7
--------------------------- ---------------------------
* Improved error handling: * 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 to set the PSYCOPG_DEBUG environment variable to turn on debug
spew. spew.
What's new in psycopg 2.0.6 What's new in psycopg 2.0.6
--------------------------- ---------------------------

View File

@ -18,7 +18,7 @@
# See the LICENSE file for details. # See the LICENSE file for details.
ALLOWED_PSYCOPG_VERSIONS = ('2.0.6',) ALLOWED_PSYCOPG_VERSIONS = ('2.0.7',)
import sys import sys
import time import time

View File

@ -406,17 +406,18 @@ psyco_TimestampFromTicks(PyObject *self, PyObject *args)
t = (time_t)round(ticks); t = (time_t)round(ticks);
ticks -= (double)t; ticks -= (double)t;
if (localtime_r(&t, &tm)) { if (localtime_r(&t, &tm)) {
args = Py_BuildValue("iiiiidO", PyObject *value = Py_BuildValue("iiiiidO",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_hour, tm.tm_min,
(double)tm.tm_sec + ticks, (double)tm.tm_sec + ticks,
pyPsycopgTzLOCAL); pyPsycopgTzLOCAL);
if (args) { if (value) {
/* Dprintf("psyco_TimestampFromTicks: args->refcnt = %d", args->ob_refcnt);*/ /* we don't decref the value here because the call to
res = psyco_Timestamp(self, args); psyco_Timestamp will do that by calling PyArg_ParseTuple */
Py_DECREF(args); res = psyco_Timestamp(self, value);
} }
} }
return res; return res;
} }

View File

@ -54,7 +54,7 @@ from distutils.command.build_ext import build_ext
from distutils.sysconfig import get_python_inc from distutils.sysconfig import get_python_inc
from distutils.ccompiler import get_default_compiler from distutils.ccompiler import get_default_compiler
PSYCOPG_VERSION = '2.0.6' PSYCOPG_VERSION = '2.0.7'
version_flags = [] version_flags = []
PLATFORM_IS_WINDOWS = sys.platform.lower().startswith('win') PLATFORM_IS_WINDOWS = sys.platform.lower().startswith('win')