Fixed compiling on Python versions before 2.6

Added a few macros not defined in Py 2.4. Don't know about 2.5.
This commit is contained in:
Daniele Varrazzo 2011-01-03 19:14:40 +01:00
parent 9eae66e8cf
commit b276e3b05d
3 changed files with 10 additions and 1 deletions

View File

@ -80,6 +80,10 @@
#define PSYCOPG_MODULE #define PSYCOPG_MODULE
#include "psycopg/psycopg.h" #include "psycopg/psycopg.h"
#ifndef Py_LOCAL_INLINE
#define Py_LOCAL_INLINE(type) static type
#endif
/* Helpers for formatstring */ /* Helpers for formatstring */
Py_LOCAL_INLINE(PyObject *) Py_LOCAL_INLINE(PyObject *)

View File

@ -62,6 +62,11 @@
#define PyVarObject_HEAD_INIT(x,n) PyObject_HEAD_INIT(x) n, #define PyVarObject_HEAD_INIT(x,n) PyObject_HEAD_INIT(x) n,
#endif #endif
/* Missing at least in Python 2.4 */
#ifndef Py_MEMCPY
#define Py_MEMCPY memcpy
#endif
/* FORMAT_CODE_PY_SSIZE_T is for Py_ssize_t: */ /* FORMAT_CODE_PY_SSIZE_T is for Py_ssize_t: */
#define FORMAT_CODE_PY_SSIZE_T "%" PY_FORMAT_SIZE_T "d" #define FORMAT_CODE_PY_SSIZE_T "%" PY_FORMAT_SIZE_T "d"

View File

@ -438,7 +438,7 @@ typecast_repr(PyObject *self)
} }
rv = PyString_FromFormat("<%s '%s' at %p>", rv = PyString_FromFormat("<%s '%s' at %p>",
Py_TYPE(self)->tp_name, PyBytes_AS_STRING(name), self); Py_TYPE(self)->tp_name, Bytes_AS_STRING(name), self);
Py_DECREF(name); Py_DECREF(name);
return rv; return rv;