Miscellaneous fixes for Python, mostly version 3
Showing the changes to python/ext (6 of 10 files). Show all
Unified · Split
| @@ -39,6 +39,11 @@ · 38 unmodified lines | ||
| 39 | 39 | #define AUBIO_NPY_SMPL NPY_FLOAT |
| 40 | 40 | #endif |
| 41 | 41 | |
| 42 | +// compat with Python < 2.6 | |
| 43 | +#ifndef Py_TYPE | |
| 44 | +#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) | |
| 45 | +#endif | |
| 46 | + | |
| 42 | 47 | // special python type for cvec |
| 43 | 48 | typedef struct |
| 44 | 49 | { |
| @@ -13,7 +13,7 @@ Py_ ## NAME ## _init (Py_ ## NAME * self, PyObject * args, PyObject * kwds) \ · 12 unmodified lines | ||
| 13 | 13 | { \ |
| 14 | 14 | self->o = new_aubio_## NAME ( PARAMS ); \ |
| 15 | 15 | if (self->o == NULL) { \ |
| 16 | − PyErr_SetString (PyExc_StandardError, "error creating object"); \ | |
| 16 | + PyErr_SetString (PyExc_RuntimeError, "error creating object"); \ | |
| 17 | 17 | return -1; \ |
| 18 | 18 | } \ |
| 19 | 19 | \ |
| @@ -25,7 +25,7 @@ static void \ · 5 unmodified lines | ||
| 25 | 25 | Py_ ## NAME ## _del ( Py_ ## NAME * self) \ |
| 26 | 26 | { \ |
| 27 | 27 | del_aubio_ ## NAME (self->o); \ |
| 28 | − self->ob_type->tp_free ((PyObject *) self); \ | |
| 28 | + Py_TYPE(self)->tp_free ((PyObject *) self); \ | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | #define AUBIO_MEMBERS_START(NAME) \ |
| @@ -59,7 +59,7 @@ static void · 58 unmodified lines | ||
| 59 | 59 | Py_cvec_del (Py_cvec * self) |
| 60 | 60 | { |
| 61 | 61 | del_cvec (self->o); |
| 62 | − self->ob_type->tp_free ((PyObject *) self); | |
| 62 | + Py_TYPE(self)->tp_free ((PyObject *) self); | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | static PyObject * |
| @@ -57,7 +57,7 @@ Py_filter_del (Py_filter * self) · 56 unmodified lines | ||
| 57 | 57 | { |
| 58 | 58 | del_fvec(self->out); |
| 59 | 59 | del_aubio_filter (self->o); |
| 60 | − self->ob_type->tp_free ((PyObject *) self); | |
| 60 | + Py_TYPE(self)->tp_free ((PyObject *) self); | |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | static PyObject * |
| @@ -115,7 +115,7 @@ Py_sink_init (Py_sink * self, PyObject * args, PyObject * kwds) · 114 unmodified lines | ||
| 115 | 115 | aubio_sink_preset_samplerate ( self->o, self->samplerate ); |
| 116 | 116 | } |
| 117 | 117 | if (self->o == NULL) { |
| 118 | − PyErr_SetString (PyExc_StandardError, "error creating sink with this uri"); | |
| 118 | + PyErr_SetString (PyExc_RuntimeError, "error creating sink with this uri"); | |
| 119 | 119 | return -1; |
| 120 | 120 | } |
| 121 | 121 | self->samplerate = aubio_sink_get_samplerate ( self->o ); |
| @@ -139,7 +139,7 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 138 unmodified lines | ||
| 139 | 139 | if (self->o == NULL) { |
| 140 | 140 | char_t errstr[30 + strlen(self->uri)]; |
| 141 | 141 | sprintf(errstr, "error creating source with %s", self->uri); |
| 142 | − PyErr_SetString (PyExc_StandardError, errstr); | |
| 142 | + PyErr_SetString (PyExc_RuntimeError, errstr); | |
| 143 | 143 | return -1; |
| 144 | 144 | } |
| 145 | 145 | self->samplerate = aubio_source_get_samplerate ( self->o ); |