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 ncoghlan
Recipients kermode, mark.dickinson, ncoghlan, pitrou, teoliphant
Date 2011-01-07.10:01:41
SpamBayes Score 4.1172825e-09
Marked as misclassified No
Message-id <1294394503.75.0.518735272621.issue9990@psf.upfronthosting.co.za>
In-reply-to
Content
The alternative (if we declare that clients should treat Py_buffer contents as completely read-only) is to update memoryview to include a separate "orig_view" field that would never be touched. The GetBuffer and ReleaseBuffer calls would then use orig_view, with dup_buffer used to copy the data into the main view field before modifying it.

However, this approach greatly complicates the bf_getbuffer and bf_releasebuffer implementations, since memoryview could no longer pass the supplied Py_buffer pointer straight through to the underlying implementation.

Instead, for each call to bf_getbuffer, it would need to create a new Py_buffer struct, use that for the GetBuffer call to the underlying object, copy the contents over to the passed in buffer (modifying the shape information as appropriate for any slicing that is in effect), then, in bf_releasebuffer, use the passed in pointer to find the right Py_buffer struct to use in the ReleaseBuffer call.

Putting the onus on exporters to be suspicious of the contents of the Py_buffer objects handed to bf_releasebuffer implementations actually seems like the more robust approach in the long run.
History
Date User Action Args
2011-01-07 10:01:43ncoghlansetrecipients: + ncoghlan, teoliphant, mark.dickinson, kermode, pitrou
2011-01-07 10:01:43ncoghlansetmessageid: <1294394503.75.0.518735272621.issue9990@psf.upfronthosting.co.za>
2011-01-07 10:01:41ncoghlanlinkissue9990 messages
2011-01-07 10:01:41ncoghlancreate