This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients Alexander.Belopolsky, belopolsky, docs@python, ncoghlan, pitrou, skrah
Date 2012-08-31.21:06:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1346447170.51.0.944082632726.issue15821@psf.upfronthosting.co.za>
In-reply-to
Content
Here is what I think the test case should look like (untested):


static PyObject *
memoryview_from_buffer_cleanup(PyObject *self, PyObject *noargs)
{
    PyObject *b, *view = NULL;
    Py_buffer info;
    Py_ssize_t shape[3] = {2, 2, 3};
    Py_ssize_t strides[3] = {6, 3, 1};
    const char *cp = "abcdefghijkl";

    b = PyBytes_FromString(cp);
    if (b == NULL)
        return NULL;

    if (PyObject_GetBuffer(b, &info, PyBUF_FULL_RO) < 0)
        goto done;
    /* reshape */
    info.ndim = 3;
    info.shape = shape;
    info.strides = strides;

    view = PyMemoryView_FromBuffer(&info);
    /* release resources allocated for Py_buffer struct 
       before it goes out of scope */
    PyBuffer_Release(&info);
 done:
    Py_DECREF(b);
    return view;
}
History
Date User Action Args
2012-08-31 21:06:10belopolskysetrecipients: + belopolsky, ncoghlan, pitrou, skrah, Alexander.Belopolsky, docs@python
2012-08-31 21:06:10belopolskysetmessageid: <1346447170.51.0.944082632726.issue15821@psf.upfronthosting.co.za>
2012-08-31 21:06:09belopolskylinkissue15821 messages
2012-08-31 21:06:08belopolskycreate