Message223611
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. |
|
Date |
User |
Action |
Args |
2014-07-21 22:03:25 | dw | set | recipients:
+ dw, pitrou, scoder, benjamin.peterson, stutzbach, skrah, hynek, serhiy.storchaka, kmike |
2014-07-21 22:03:25 | dw | set | messageid: <1405980205.22.0.727196794194.issue22003@psf.upfronthosting.co.za> |
2014-07-21 22:03:25 | dw | link | issue22003 messages |
2014-07-21 22:03:25 | dw | create | |
|