Stefan Krah added the comment:

Alexander, your test case is brilliant and could eventually go into
_testbuffer.c, but I'd prefer a simpler test case for now. :)

Here's a patch that restores the info.obj cleanup facility.

I intentionally did not add copying the format in order to keep the
diff small (in case this can go into rc2). Crashing on stack addresses
for format is not a regression.


Apparently PyMemoryView_FromBuffer() is used for low level tinkering and
automatic cleanup, so I now think that it's better not to break backwards
compatibility, i.e. leave the value of info.obj untouched.

Otherwise people using the cleanup facility will have reference leaks.


However, I don't like the interface at all: Passing a pointer to a struct
and then relying on the fact that *some* values are copied (shape, strides
and suboffsets) but not others (format, buf) is counterintuitive.


With the ManagedBuffer, we could now write a new function that returns
a memoryview with much nicer cleanup facilities. But that doesn't help
here since we're stuck with this function for 3.3.0.


What do you think? Should this go into 3.3.0? The changes to memoryobject.c
are minimal, the rest are tests and docs.

----------
assignee: docs@python -> skrah
components: +Interpreter Core -Documentation
stage:  -> patch review
title: Improve docs for PyMemoryView_FromBuffer() -> PyMemoryView_FromBuffer() 
behavior change (possible regression)
type: enhancement -> behavior
Added file: http://bugs.python.org/file27076/issue15821.diff

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

Reply via email to