python/ext: continue preparing for python 3
authorPaul Brossier <piem@piem.org>
Mon, 18 Apr 2016 20:53:24 +0000 (22:53 +0200)
committerPaul Brossier <piem@piem.org>
Mon, 18 Apr 2016 20:53:24 +0000 (22:53 +0200)
python/ext/aubiowraphell.h
python/ext/py-cvec.c
python/ext/py-fft.c
python/ext/py-filter.c
python/ext/py-filterbank.c
python/ext/py-phasevoc.c
python/ext/py-source.c

index c75567d..3b17038 100644 (file)
@@ -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,                           \
index a060696..8c0a4eb 100644 (file)
@@ -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       */
index 51a7677..5227000 100644 (file)
@@ -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 * 
index abbdad8..732b366 100644 (file)
@@ -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       */
index 1f40e16..00cac70 100644 (file)
@@ -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 *
index 2b80082..91efa06 100644 (file)
@@ -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);
 }
 
 
index c89c163..fde99e3 100644 (file)
@@ -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 *