[New-bugs-announce] [issue3693] Obscure array.array error message
Terry J. Reedy
report at bugs.python.org
Wed Aug 27 03:51:36 CEST 2008
New submission from Terry J. Reedy <tjreedy at udel.edu>:
In 2.5
>>> import array
>>> a = array.array('b', 'fox')
>>>
In 3.0
>>> import array
>>> a = array.array('b', 'fox')
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = array.array('b', 'fox')
TypeError: an integer is required
This puzzled me because an integer argument most certainly is not
allowed (one would raise other exceptions.) Then I realized that 'an
integer' here actually means 'an iterator producing integers' or more
exactly, 'an iterable whose iterator yields integers in the range
implied by the type code'. What I would like to see is something like
TypeError: for typecode 'b', the optional initializer must be an
iterable of 1 byte integers (such as bytes).
I would also like to see a minor change in the array and array.array
docstrings. Array.__doc__ lists the typecodes, array.array.__doc__
lists all the other info needed, so that help(array) gives everything
while help(array.array) omits the needed typecode info. So I would like
to see the typecode info moved to the class docstring with everything
else (and replaced by 'Defines one class: array') so help(array) and
help(array.array) would both give all needed info.
----------
components: Library (Lib)
messages: 72004
nosy: tjreedy
severity: normal
status: open
title: Obscure array.array error message
versions: Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3693>
_______________________________________
More information about the New-bugs-announce
mailing list