Nick Coghlan <ncogh...@gmail.com> added the comment:

@Antoine: I actually had a closer look at the way dup_buffer is used, and I 
think it is currently legitimate (including for the anonymous memory case). It 
just isn't documented very well. For the "FromBuffer" case, it assumes the 
calling code already invoked GetBuffer as necessary when initialising the view, 
and for the various internal uses the dup_buffer call is immediately preceded 
by a GetBuffer call when view->obj is not NULL.

@Mark: I don't think that follows. PEP 3118 says that exporting objects own 
that memory, but it doesn't say that clients have to treat the structures as 
read-only. The only thing clients are obligated to do is pass the same 
Py_buffer address to ReleaseBuffer that was passed to GetBuffer. If the 
exporter actually needs to release buffer specific resources, then it should 
maintain an internal data structure keyed off the Py_buffer address.

The one thing clients really shouldn't mess with is the obj field (since 
ReleaseBuffer needs that to find the correct release method to invoke), but the 
PEP is obviously silent on that matter since it doesn't even acknowledge the 
existence of that field.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10181>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to