[docs] [issue15821] PyMemoryView_FromBuffer() behavior change (possible regression)
Alexander Belopolsky
report at bugs.python.org
Fri Aug 31 23:06:10 CEST 2012
Alexander Belopolsky added the comment:
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;
}
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15821>
_______________________________________
More information about the docs
mailing list