summaryrefslogtreecommitdiff
path: root/psycopg/python.h
diff options
context:
space:
mode:
authorJames Henstridge <james@jamesh.id.au>2008-12-26 09:37:44 +0900
committerJames Henstridge <james@jamesh.id.au>2008-12-26 09:37:44 +0900
commite7b8d6505e89571c7637d0377f6a4ce2cc6106b0 (patch)
tree6bc8f0731008a3dacedd79ab5944c506148a77eb /psycopg/python.h
parent5480cf53328d78546e4c0b126e807535c4bc900f (diff)
downloadpsycopg2-e7b8d6505e89571c7637d0377f6a4ce2cc6106b0.tar.gz
Remove backward compatibility support for Python versions older than
2.4, since we don't really support them any way.
Diffstat (limited to 'psycopg/python.h')
-rw-r--r--psycopg/python.h54
1 files changed, 24 insertions, 30 deletions
diff --git a/psycopg/python.h b/psycopg/python.h
index 13d6ce7..22cae4a 100644
--- a/psycopg/python.h
+++ b/psycopg/python.h
@@ -26,42 +26,36 @@
#include <Python.h>
#include <structmember.h>
-/* python < 2.2 does not have PyMemeberDef */
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2
-#define PyMemberDef memberlist
+#if PY_VERSION_HEX < 0x02040000
+# error "psycopg requires Python >= 2.4"
#endif
-/* PyObject_TypeCheck introduced in 2.2 */
-#ifndef PyObject_TypeCheck
-#define PyObject_TypeCheck(o, t) ((o)->ob_type == (t))
-#endif
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+ typedef int Py_ssize_t;
+ #define PY_SSIZE_T_MIN INT_MIN
+ #define PY_SSIZE_T_MAX INT_MAX
+ #define PY_FORMAT_SIZE_T ""
-/* python 2.2 does not have freefunc (it has destructor instead) */
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 3
-#define freefunc destructor
-#endif
+ #define readbufferproc getreadbufferproc
+ #define writebufferproc getwritebufferproc
+ #define segcountproc getsegcountproc
+ #define charbufferproc getcharbufferproc
-/* Py_VISIT and Py_CLEAR introduced in Python 2.4 */
-#ifndef Py_VISIT
-#define Py_VISIT(op) \
- do { \
- if (op) { \
- int vret = visit((op), arg); \
- if (vret) \
- return vret; \
- } \
- } while (0)
+ #define CONV_CODE_PY_SSIZE_T "i"
+#else
+ #define CONV_CODE_PY_SSIZE_T "n"
#endif
-#ifndef Py_CLEAR
-#define Py_CLEAR(op) \
- do { \
- if (op) { \
- PyObject *tmp = (PyObject *)(op); \
- (op) = NULL; \
- Py_DECREF(tmp); \
- } \
- } while (0)
+/* FORMAT_CODE_PY_SSIZE_T is for Py_ssize_t: */
+#define FORMAT_CODE_PY_SSIZE_T "%" PY_FORMAT_SIZE_T "d"
+
+/* FORMAT_CODE_SIZE_T is for plain size_t, not for Py_ssize_t: */
+#ifdef _MSC_VER
+ /* For MSVC: */
+ #define FORMAT_CODE_SIZE_T "%Iu"
+#else
+ /* C99 standard format code: */
+ #define FORMAT_CODE_SIZE_T "%zu"
#endif
#endif /* !defined(PSYCOPG_PYTHON_H) */