mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-03 15:45:46 +03:00
Remove backward compatibility support for Python versions older than
2.4, since we don't really support them any way.
This commit is contained in:
parent
5480cf5332
commit
e7b8d6505e
|
@ -27,42 +27,12 @@
|
||||||
#include <libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
|
|
||||||
#include "psycopg/config.h"
|
#include "psycopg/config.h"
|
||||||
|
#include "psycopg/python.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Python 2.5+ Py_ssize_t compatibility: */
|
|
||||||
#ifndef PY_FORMAT_SIZE_T
|
|
||||||
#define PY_FORMAT_SIZE_T ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
/* FORMAT_CODE_PY_SSIZE_T is for Py_ssize_t: */
|
|
||||||
#define FORMAT_CODE_PY_SSIZE_T "%" PY_FORMAT_SIZE_T "d"
|
|
||||||
|
|
||||||
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5
|
|
||||||
#define CONV_CODE_PY_SSIZE_T "n"
|
|
||||||
#else
|
|
||||||
#define CONV_CODE_PY_SSIZE_T "i"
|
|
||||||
|
|
||||||
typedef int Py_ssize_t;
|
|
||||||
#define PY_SSIZE_T_MIN INT_MIN
|
|
||||||
#define PY_SSIZE_T_MAX INT_MAX
|
|
||||||
|
|
||||||
#define readbufferproc getreadbufferproc
|
|
||||||
#define writebufferproc getwritebufferproc
|
|
||||||
#define segcountproc getsegcountproc
|
|
||||||
#define charbufferproc getcharbufferproc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* DBAPI compliance parameters */
|
/* DBAPI compliance parameters */
|
||||||
#define APILEVEL "2.0"
|
#define APILEVEL "2.0"
|
||||||
#define THREADSAFETY 2
|
#define THREADSAFETY 2
|
||||||
|
|
|
@ -26,42 +26,36 @@
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <structmember.h>
|
#include <structmember.h>
|
||||||
|
|
||||||
/* python < 2.2 does not have PyMemeberDef */
|
#if PY_VERSION_HEX < 0x02040000
|
||||||
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2
|
# error "psycopg requires Python >= 2.4"
|
||||||
#define PyMemberDef memberlist
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* PyObject_TypeCheck introduced in 2.2 */
|
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
|
||||||
#ifndef PyObject_TypeCheck
|
typedef int Py_ssize_t;
|
||||||
#define PyObject_TypeCheck(o, t) ((o)->ob_type == (t))
|
#define PY_SSIZE_T_MIN INT_MIN
|
||||||
|
#define PY_SSIZE_T_MAX INT_MAX
|
||||||
|
#define PY_FORMAT_SIZE_T ""
|
||||||
|
|
||||||
|
#define readbufferproc getreadbufferproc
|
||||||
|
#define writebufferproc getwritebufferproc
|
||||||
|
#define segcountproc getsegcountproc
|
||||||
|
#define charbufferproc getcharbufferproc
|
||||||
|
|
||||||
|
#define CONV_CODE_PY_SSIZE_T "i"
|
||||||
|
#else
|
||||||
|
#define CONV_CODE_PY_SSIZE_T "n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* python 2.2 does not have freefunc (it has destructor instead) */
|
/* FORMAT_CODE_PY_SSIZE_T is for Py_ssize_t: */
|
||||||
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 3
|
#define FORMAT_CODE_PY_SSIZE_T "%" PY_FORMAT_SIZE_T "d"
|
||||||
#define freefunc destructor
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Py_VISIT and Py_CLEAR introduced in Python 2.4 */
|
/* FORMAT_CODE_SIZE_T is for plain size_t, not for Py_ssize_t: */
|
||||||
#ifndef Py_VISIT
|
#ifdef _MSC_VER
|
||||||
#define Py_VISIT(op) \
|
/* For MSVC: */
|
||||||
do { \
|
#define FORMAT_CODE_SIZE_T "%Iu"
|
||||||
if (op) { \
|
#else
|
||||||
int vret = visit((op), arg); \
|
/* C99 standard format code: */
|
||||||
if (vret) \
|
#define FORMAT_CODE_SIZE_T "%zu"
|
||||||
return vret; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef Py_CLEAR
|
|
||||||
#define Py_CLEAR(op) \
|
|
||||||
do { \
|
|
||||||
if (op) { \
|
|
||||||
PyObject *tmp = (PyObject *)(op); \
|
|
||||||
(op) = NULL; \
|
|
||||||
Py_DECREF(tmp); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !defined(PSYCOPG_PYTHON_H) */
|
#endif /* !defined(PSYCOPG_PYTHON_H) */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user