Message223611
| Author |
dw |
| Recipients |
benjamin.peterson, dw, hynek, kmike, pitrou, scoder, serhiy.storchaka, skrah, stutzbach |
| Date |
2014年07月21日.22:03:25 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1405980205.22.0.727196794194.issue22003@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|