Changeset 966c650


Ignore:
Timestamp:
Dec 23, 2018, 5:46:47 AM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
Children:
cd46892
Parents:
79dc9ad
Message:

[py] take a copy for the last source block when iterating

Appears to be the simplest solution to prevent resizing internal objects.
See also 8e76c71.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-source.c

    r79dc9ad r966c650  
    582582    } else if (PyLong_AsLong(size) > 0) {
    583583      // short read, return a shorter array
    584       PyArrayObject *shortread = (PyArrayObject*)PyTuple_GetItem(done, 0);
     584      PyObject *vec = PyTuple_GetItem(done, 0);
     585      // take a copy to prevent resizing internal arrays
     586      PyArrayObject *shortread = PyArray_FROM_OTF(vec, NPY_NOTYPE,
     587          NPY_ARRAY_ENSURECOPY);
    585588      PyArray_Dims newdims;
    586589      PyObject *reshaped;
     
    595598      reshaped = PyArray_Newshape(shortread, &newdims, NPY_CORDER);
    596599      Py_DECREF(shortread);
     600      Py_DECREF(vec);
    597601      return reshaped;
    598602    } else {
Note: See TracChangeset for help on using the changeset viewer.