From 8b7cdbad05db492a86eef2dc48bba1740b6afdf1 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 27 Feb 2017 17:21:34 +0100 Subject: [PATCH] python/ext/py-source.c: use PyArray_NewShape, not _Resize --- python/ext/py-source.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; -- 2.11.0