Message253702
Before the Issue 22896 changes, PyObject_AsWriteBuffer() was used, which requests a buffer with the PyBUF_WRITABLE flag. Currently we use “w*” argument parsing format, which also uses PyBUF_WRITABLE. (Incidentally, I suspect the C-contiguity check is redundant for “w*”; non-contiguous buffers trigger the “read-write” error instead.)
Now Eryksun’s patch changes to PyMemoryView_FromObject(), which requests a buffer with the PyBUF_FULL_RO flag (the most liberal), and only then checks for writability and contiguity. Could this be a problem for some kind of object that returns different buffers depending on the request flags?
I agree that the existing buffer and memory view APIs don’t seem to be very practical and well understood. PyMemoryView_FromBuffer() is also used in the “io” module. It doesn’t even try to save a reference to the underlying buffers, meaning it is possible for Python code to write into freed memory by saving the memory view object passed to the readinto() method. |
|
Date |
User |
Action |
Args |
2015-10-29 23:37:58 | martin.panter | set | recipients:
+ martin.panter, jnoller, r.david.murray, skrah, sbt, zach.ware, serhiy.storchaka, JakeMont |
2015-10-29 23:37:58 | martin.panter | set | messageid: <1446161878.07.0.265717647024.issue25498@psf.upfronthosting.co.za> |
2015-10-29 23:37:58 | martin.panter | link | issue25498 messages |
2015-10-29 23:37:57 | martin.panter | create | |
|