[issue26720] memoryview from BufferedWriter becomes garbage
Martin Panter
report at bugs.python.org
Mon Apr 11 05:29:54 EDT 2016
Martin Panter added the comment:
To create a memoryview with unlimited lifetime, I understand we need to nominate an “exporting object”, which becomes memoryview.obj. Using a bytes object here might be the simplest fix for just BufferedWriter.
However it looks like the buffer is shared with BufferedReader and others. To fix the analogous bug with BufferedReader, a bytearray might be better, because the user could see it being mutated when reading into the memoryview.
I think bytearray might be okay for BufferedWriter too, as long as we prevent it being resized. The user would be able to alter the contents of the buffer, but I don’t see that as a problem. An alternative would be a new opaque object that doesn’t do much except have a reference count.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26720>
_______________________________________
More information about the Python-bugs-list
mailing list