[issue8990] array constructor and array.fromstring should accept bytearray.

Thomas Jollans report at bugs.python.org
Mon Jun 21 22:09:51 CEST 2010


Thomas Jollans <thomas at jollans.com> added the comment:

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:

1. ignore the item size. This'd be similar to current behaviour, plus r/w buffers

2. only accept byte-based buffers. ("things that look like 'const char*'") - this is what I've been aiming at.

3. 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?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8990>
_______________________________________


More information about the Python-bugs-list mailing list