Message 108312 - Python tracker (original) (raw)
Thanks for the input. I'm going to re-work the patch a bit (releasing buffers and such) and add a test within the next few days.
The question remains whether or not to accept other buffers with itemsize == 1. The way I understand it, fromstring already accepted any read-only buffer object, no matter the item size / whether it actually makes sense to call it a "string". I don't think accepting a hypothetical read-only buffer with items wider than 1 in fromstring (yes, bad naming) is desirable behaviour - I see a few options on how to deal with input validation:
ignore the item size. This'd be similar to current behaviour, plus r/w buffers
only accept byte-based buffers. ("things that look like 'const char*'") - this is what I've been aiming at.
only accept bytes and bytearray, and let the user think about how to deal with other objects. Question is - shouldn't array('B') be treated like bytearray in this respect?