From: Paul Brossier Date: Mon, 18 Apr 2016 20:53:24 +0000 (+0200) Subject: python/ext: continue preparing for python 3 X-Git-Tag: 0.4.4~300^2~318 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=5c1200a07d442662cc3279233173686679737953;p=aubio.git python/ext: continue preparing for python 3 --- diff --git a/python/ext/aubiowraphell.h b/python/ext/aubiowraphell.h index c75567d7..3b170384 100644 --- a/python/ext/aubiowraphell.h +++ b/python/ext/aubiowraphell.h @@ -43,8 +43,7 @@ static PyMethodDef Py_ ## NAME ## _methods[] = { \ #define AUBIO_TYPEOBJECT(NAME, PYNAME) \ PyTypeObject Py_ ## NAME ## Type = { \ - PyObject_HEAD_INIT (NULL) \ - 0, \ + PyVarObject_HEAD_INIT (NULL, 0) \ PYNAME, \ sizeof (Py_ ## NAME), \ 0, \ diff --git a/python/ext/py-cvec.c b/python/ext/py-cvec.c index a0606968..8c0a4eb9 100644 --- a/python/ext/py-cvec.c +++ b/python/ext/py-cvec.c @@ -69,7 +69,7 @@ Py_cvec_repr (Py_cvec * self, PyObject * unused) PyObject *args = NULL; PyObject *result = NULL; - format = PyString_FromString ("aubio cvec of %d elements"); + format = PyUnicode_FromString ("aubio cvec of %d elements"); if (format == NULL) { goto fail; } @@ -80,7 +80,7 @@ Py_cvec_repr (Py_cvec * self, PyObject * unused) } cvec_print ( self->o ); - result = PyString_Format (format, args); + result = PyUnicode_Format (format, args); fail: Py_XDECREF (format); @@ -260,8 +260,7 @@ static PyGetSetDef Py_cvec_getseters[] = { }; PyTypeObject Py_cvecType = { - PyObject_HEAD_INIT (NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "aubio.cvec", /* tp_name */ sizeof (Py_cvec), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/python/ext/py-fft.c b/python/ext/py-fft.c index 51a76775..52270003 100644 --- a/python/ext/py-fft.c +++ b/python/ext/py-fft.c @@ -50,7 +50,7 @@ Py_fft_init (Py_fft * self, PyObject * args, PyObject * kwds) if (self->o == NULL) { char_t errstr[30]; sprintf(errstr, "error creating fft with win_s=%d", self->win_s); - PyErr_SetString (PyExc_StandardError, errstr); + PyErr_SetString (PyExc_Exception, errstr); return -1; } self->out = new_cvec(self->win_s); @@ -65,7 +65,7 @@ Py_fft_del (Py_fft *self, PyObject *unused) del_aubio_fft(self->o); del_cvec(self->out); del_fvec(self->rout); - self->ob_type->tp_free((PyObject *) self); + Py_TYPE(self)->tp_free((PyObject *) self); } static PyObject * diff --git a/python/ext/py-filter.c b/python/ext/py-filter.c index abbdad82..732b3669 100644 --- a/python/ext/py-filter.c +++ b/python/ext/py-filter.c @@ -162,8 +162,7 @@ static PyMethodDef Py_filter_methods[] = { }; PyTypeObject Py_filterType = { - PyObject_HEAD_INIT (NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "aubio.digital_filter", /* tp_name */ sizeof (Py_filter), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/python/ext/py-filterbank.c b/python/ext/py-filterbank.c index 1f40e16f..00cac701 100644 --- a/python/ext/py-filterbank.c +++ b/python/ext/py-filterbank.c @@ -59,7 +59,7 @@ Py_filterbank_init (Py_filterbank * self, PyObject * args, PyObject * kwds) char_t errstr[30]; sprintf(errstr, "error creating filterbank with n_filters=%d, win_s=%d", self->n_filters, self->win_s); - PyErr_SetString (PyExc_StandardError, errstr); + PyErr_SetString (PyExc_RuntimeError, errstr); return -1; } self->out = new_fvec(self->n_filters); @@ -72,7 +72,7 @@ Py_filterbank_del (Py_filterbank *self, PyObject *unused) { del_aubio_filterbank(self->o); del_fvec(self->out); - self->ob_type->tp_free((PyObject *) self); + Py_TYPE(self)->tp_free((PyObject *) self); } static PyObject * diff --git a/python/ext/py-phasevoc.c b/python/ext/py-phasevoc.c index 2b800827..91efa06b 100644 --- a/python/ext/py-phasevoc.c +++ b/python/ext/py-phasevoc.c @@ -70,7 +70,7 @@ Py_pvoc_del (Py_pvoc *self, PyObject *unused) del_aubio_pvoc(self->o); del_cvec(self->output); del_fvec(self->routput); - self->ob_type->tp_free((PyObject *) self); + Py_TYPE(self)->tp_free((PyObject *) self); } diff --git a/python/ext/py-source.c b/python/ext/py-source.c index c89c1633..fde99e3f 100644 --- a/python/ext/py-source.c +++ b/python/ext/py-source.c @@ -159,7 +159,7 @@ Py_source_del (Py_source *self, PyObject *unused) del_aubio_source(self->o); del_fvec(self->read_to); del_fmat(self->mread_to); - self->ob_type->tp_free((PyObject *) self); + Py_TYPE(self)->tp_free((PyObject *) self); } @@ -186,7 +186,7 @@ Py_source_do(Py_source * self, PyObject * args) PyObject *outputs = PyList_New(0); PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (self->read_to)); - PyList_Append( outputs, (PyObject *)PyInt_FromLong (read)); + PyList_Append( outputs, (PyObject *)PyLong_FromLong(read)); return outputs; } @@ -213,7 +213,7 @@ Py_source_do_multi(Py_source * self, PyObject * args) PyObject *outputs = PyList_New(0); PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (self->mread_to)); - PyList_Append( outputs, (PyObject *)PyInt_FromLong (read)); + PyList_Append( outputs, (PyObject *)PyLong_FromLong(read)); return outputs; } @@ -233,14 +233,14 @@ static PyObject * Pyaubio_source_get_samplerate (Py_source *self, PyObject *unused) { uint_t tmp = aubio_source_get_samplerate (self->o); - return (PyObject *)PyInt_FromLong (tmp); + return (PyObject *)PyLong_FromLong (tmp); } static PyObject * Pyaubio_source_get_channels (Py_source *self, PyObject *unused) { uint_t tmp = aubio_source_get_channels (self->o); - return (PyObject *)PyInt_FromLong (tmp); + return (PyObject *)PyLong_FromLong (tmp); } static PyObject *