Message286785
| Author |
vstinner |
| Recipients |
larry, martin.panter, methane, python-dev, serhiy.storchaka, vstinner |
| Date |
2017年02月02日.13:34:51 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1486042491.68.0.227427220935.issue29300@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Martin Panter: """FYI Victor, you can make non-C-contiguous buffers by slicing memoryview:
>>> struct.unpack(">L", memoryview(b"1234")[::-1])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
BufferError: memoryview: underlying buffer is not C-contiguous"""
Oh, it means that the Argument Clinic change doesn't add new checks on the buffer? In Python 3.6, memory_getbuf() raises an exception in the following code:
if (!REQ_STRIDES(flags)) {
if (!MV_C_CONTIGUOUS(baseflags)) {
PyErr_SetString(PyExc_BufferError,
"memoryview: underlying buffer is not C-contiguous");
return -1;
}
view->strides = NULL;
}
I undersrtand that memory_getbuf() is smart enough to raise an exception becaues the buffer is not contiguous. But a weaker implementation of getbuffer may not implement such check, whereas getbuffer() double check that the buffer is C-contiguous. Am I right? |
|