From 9dc68111352716cb242d12f49c3a5d232299a0e2 Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Fri, 18 Feb 2011 11:52:17 -0700 Subject: [PATCH 1/2] Again, increase timeout on concurrent_exec tests Truly increase the sleep timeout to 4 seconds and the check to 7. Previous commit message indicated that, but reality was different. --- tests/test_connection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index 219c0938..ef63470f 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -119,7 +119,7 @@ class ConnectionTests(unittest.TestCase): def slave(): cnn = psycopg2.connect(dsn) cur = cnn.cursor() - cur.execute("select pg_sleep(3)") + cur.execute("select pg_sleep(4)") cur.close() cnn.close() @@ -130,7 +130,7 @@ class ConnectionTests(unittest.TestCase): t2.start() t1.join() t2.join() - self.assert_(time.time() - t0 < 5, + self.assert_(time.time() - t0 < 7, "something broken in concurrency") def test_encoding_name(self): From 4bc47d47a5e4570a66b1da393776c4a306feecb6 Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Fri, 18 Feb 2011 23:57:25 -0700 Subject: [PATCH 2/2] Python 3.2 hash() return value is arch dependant Python 3.2 hash() function will now return a 64bit value when run on a 64bit architecture, where as previously, it would always return a 32bit value. Modified the code to use the now Py_hash_t typedef and for Python versions less than 3.2, hard code Py_hash_t to long and Py_uhash_t to unsigned long. --- psycopg/notify_type.c | 4 ++-- psycopg/python.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/psycopg/notify_type.c b/psycopg/notify_type.c index ec2ec36f..544188d4 100644 --- a/psycopg/notify_type.c +++ b/psycopg/notify_type.c @@ -189,10 +189,10 @@ exit: } -long +Py_hash_t notify_hash(NotifyObject *self) { - long rv = -1L; + Py_hash_t rv = -1L; PyObject *tself = NULL; /* if self == a tuple, then their hashes are the same. */ diff --git a/psycopg/python.h b/psycopg/python.h index c3f9a0d1..fed0303e 100644 --- a/psycopg/python.h +++ b/psycopg/python.h @@ -54,6 +54,15 @@ #define CONV_CODE_PY_SSIZE_T "n" #endif +/* hash() return size changed around version 3.2a4 on 64bit platforms. Before + * this, the return size was always a long, regardless of arch. ~3.2 + * introduced the Py_hash_t & Py_uhash_t typedefs with the resulting sizes + * based upon arch. */ +#if PY_VERSION_HEX < 0x030200A4 +typedef long Py_hash_t; +typedef unsigned long Py_uhash_t; +#endif + /* Macros defined in Python 2.6 */ #ifndef Py_REFCNT #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)