Make ctypes compatible with Python 2.3, 2.4, and 2.5 again.
This commit is contained in:
parent
340739e216
commit
ba55936b8a
|
@ -1863,8 +1863,8 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
if (PyString_Check(proto)) {
|
||||
proto_str = PyBytes_AS_STRING(proto);
|
||||
proto_len = PyBytes_GET_SIZE(proto);
|
||||
proto_str = PyString_AS_STRING(proto);
|
||||
proto_len = PyString_GET_SIZE(proto);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"class must define a '_type_' string attribute");
|
||||
|
@ -2506,6 +2506,7 @@ static PyMemberDef CData_members[] = {
|
|||
{ NULL },
|
||||
};
|
||||
|
||||
#if (PY_VERSION_HEX >= 0x02060000)
|
||||
static int CData_NewGetBuffer(PyObject *_self, Py_buffer *view, int flags)
|
||||
{
|
||||
CDataObject *self = (CDataObject *)_self;
|
||||
|
@ -2530,6 +2531,7 @@ static int CData_NewGetBuffer(PyObject *_self, Py_buffer *view, int flags)
|
|||
view->internal = NULL;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static Py_ssize_t CData_GetSegcount(PyObject *_self, Py_ssize_t *lenp)
|
||||
{
|
||||
|
@ -2554,8 +2556,10 @@ static PyBufferProcs CData_as_buffer = {
|
|||
(writebufferproc)CData_GetBuffer,
|
||||
(segcountproc)CData_GetSegcount,
|
||||
(charbufferproc)NULL,
|
||||
#if (PY_VERSION_HEX >= 0x02060000)
|
||||
(getbufferproc)CData_NewGetBuffer,
|
||||
(releasebufferproc)NULL,
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -6,11 +6,19 @@
|
|||
# include <alloca.h>
|
||||
#endif
|
||||
|
||||
#if (PY_VERSION_HEX < 0x02040000)
|
||||
#define PyDict_CheckExact(ob) (Py_TYPE(ob) == &PyDict_Type)
|
||||
#endif
|
||||
|
||||
#if (PY_VERSION_HEX < 0x02050000)
|
||||
typedef int Py_ssize_t;
|
||||
#define PyInt_FromSsize_t PyInt_FromLong
|
||||
#define PyNumber_AsSsize_t(ob, exc) PyInt_AsLong(ob)
|
||||
#define PyIndex_Check(ob) PyInt_Check(ob)
|
||||
typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **);
|
||||
typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **);
|
||||
typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *);
|
||||
typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **);
|
||||
#endif
|
||||
|
||||
#if (PY_VERSION_HEX < 0x02060000)
|
||||
|
@ -18,6 +26,8 @@ typedef int Py_ssize_t;
|
|||
#define PyVarObject_HEAD_INIT(type, size) \
|
||||
PyObject_HEAD_INIT(type) size,
|
||||
#define PyImport_ImportModuleNoBlock PyImport_ImportModule
|
||||
#define PyLong_FromSsize_t PyInt_FromLong
|
||||
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
|
||||
#endif
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue