David Wilson added the comment:

Hi Stefan,

How does this approach in reinit() look? We first ask for a writable buffer, 
and if the object obliges, immediately copy it. Otherwise if it refused, ask 
for a read-only buffer, and this time expect that it will never change.

This still does not catch the case of mmap.mmap. I am not sure how do deal with 
mmap.mmap. There is no way for it to export PROT_READ as a read-only buffer 
without permitted mutation, so the only options seem to either be a) remove 
buffer support from mmap, or b) blacklist it in bytesio(!).


Antoine, I have padded out the unit tests a little. test_memoryio.py seems the 
best place for them. Also modified test_sizeof(), although to the way this test 
is designed seems inherently brittle to begin with. Now it is also sensitive to 
changes in Py_buffer struct.


Various other changes:

* __new__ once again returns a valid, open, empty BytesIO, since the 
alternative breaks pickling.

* reinit() preserves existing BytesIO state until it knows it can succeed, 
which fixes another of the pickle tests.

* setstate() had CHECK_CLOSED() re-added, again for the pickle tests.


Probably the patch guts could be rearranged again, since the definition of the 
functions is no longer as clear as it was in cow3.patch.

----------

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

Reply via email to