From: Paul Brossier Date: Mon, 27 Feb 2017 16:21:34 +0000 (+0100) Subject: python/ext/py-source.c: use PyArray_NewShape, not _Resize X-Git-Tag: 0.4.5~74 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=8b7cdbad05db492a86eef2dc48bba1740b6afdf1;p=aubio.git python/ext/py-source.c: use PyArray_NewShape, not _Resize --- diff --git a/python/ext/py-source.c b/python/ext/py-source.c index 60108d33..219bdd42 100644 --- a/python/ext/py-source.c +++ b/python/ext/py-source.c @@ -310,9 +310,10 @@ static PyObject* Pyaubio_source_iter_next(Py_source *self) { PyObject *vec = PyTuple_GetItem(done, 0); return vec; } else if (PyLong_AsLong(size) > 0) { - // short read + // short read, return a shorter array PyArrayObject *shortread = (PyArrayObject*)PyTuple_GetItem(done, 0); PyArray_Dims newdims; + PyObject *reshaped; newdims.len = PyArray_NDIM(shortread); newdims.ptr = PyArray_DIMS(shortread); // mono or multiple channels? @@ -321,8 +322,9 @@ static PyObject* Pyaubio_source_iter_next(Py_source *self) { } else { newdims.ptr[1] = PyLong_AsLong(size); } - PyArray_Resize(shortread, &newdims, 1, NPY_ANYORDER); - return (PyObject*)shortread; + reshaped = PyArray_Newshape(shortread, &newdims, NPY_CORDER); + Py_DECREF(shortread); + return reshaped; } else { PyErr_SetNone(PyExc_StopIteration); return NULL;