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)