[New-bugs-announce] [issue8990] array constructor and array.fromstring should accept bytearray.

Thomas Jollans report at bugs.python.org
Sun Jun 13 21:42:54 CEST 2010


New submission from Thomas Jollans <thomas at jollans.com>:

Currently, the array constructor, if given a bytearray, detects this with PyByteArray_Check, and hands it on to array_fromstring, which does not support bytearray (by using "s#" with PyArg_ParseTuple) and raises TypeError.

>>> array('h', bytearray(b'xyxyxyxyxyxyxyxyxy'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: must be bytes or read-only buffer, not bytearray
>>>  


I see no reason to insist on read-only buffers. I'm attaching a patch that I think fixes this.

----------
components: Extension Modules, Library (Lib)
files: array.diff
keywords: patch
messages: 107744
nosy: tjollans
priority: normal
severity: normal
status: open
title: array constructor and array.fromstring should accept bytearray.
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file17658/array.diff

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


More information about the New-bugs-announce mailing list