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");
{ NULL },
};
+#if (PY_VERSION_HEX >= 0x02060000)
static int CData_NewGetBuffer(PyObject *_self, Py_buffer *view, int flags)
{
CDataObject *self = (CDataObject *)_self;
view->internal = NULL;
return 0;
}
+#endif
static Py_ssize_t CData_GetSegcount(PyObject *_self, Py_ssize_t *lenp)
{
(writebufferproc)CData_GetBuffer,
(segcountproc)CData_GetSegcount,
(charbufferproc)NULL,
+#if (PY_VERSION_HEX >= 0x02060000)
(getbufferproc)CData_NewGetBuffer,
(releasebufferproc)NULL,
+#endif
};
/*
# 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)
#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