ref: 5c1200a07d442662cc3279233173686679737953
parent: 2e4ae1df05117da3dbe3793d2289116bf11a9a4c
author: Paul Brossier <piem@piem.org>
date: Mon Apr 18 18:53:24 EDT 2016
python/ext: continue preparing for python 3
--- a/python/ext/aubiowraphell.h
+++ b/python/ext/aubiowraphell.h
@@ -43,8 +43,7 @@
#define AUBIO_TYPEOBJECT(NAME, PYNAME) \
PyTypeObject Py_ ## NAME ## Type = { \
- PyObject_HEAD_INIT (NULL) \
- 0, \
+ PyVarObject_HEAD_INIT (NULL, 0) \
PYNAME, \
sizeof (Py_ ## NAME), \
0, \
--- a/python/ext/py-cvec.c
+++ b/python/ext/py-cvec.c
@@ -69,7 +69,7 @@
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 @@
}
cvec_print ( self->o );
- result = PyString_Format (format, args);
+ result = PyUnicode_Format (format, args);
fail:
Py_XDECREF (format);
@@ -260,8 +260,7 @@
};
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 */
--- a/python/ext/py-fft.c
+++ b/python/ext/py-fft.c
@@ -50,7 +50,7 @@
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 @@
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 *
--- a/python/ext/py-filter.c
+++ b/python/ext/py-filter.c
@@ -162,8 +162,7 @@
};
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 */
--- a/python/ext/py-filterbank.c
+++ b/python/ext/py-filterbank.c
@@ -59,7 +59,7 @@
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 @@
{
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 *
--- a/python/ext/py-phasevoc.c
+++ b/python/ext/py-phasevoc.c
@@ -70,7 +70,7 @@
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);
}
--- a/python/ext/py-source.c
+++ b/python/ext/py-source.c
@@ -159,7 +159,7 @@
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 @@
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 @@
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,7 +233,7 @@
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 *
@@ -240,7 +240,7 @@
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 *