classification
Title: array.array falsely advertises support for 'w' in documentation
Type: Stage:
Components: Documentation, Extension Modules Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: alexandre.vassalotti, ezio.melotti, georg.brandl
Priority: low Keywords:

Created on 2009-07-06 20:40 by alexandre.vassalotti, last changed 2009-07-11 10:39 by georg.brandl. This issue is now closed.

Messages (4)
msg90190 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-07-06 20:40
It looks like either array's 'w' support got lost in a merge, or the
documentation is just wrong.


>>> import array
>>> array.array('w', "hello")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: bad typecode (must be b, B, u, h, H, i, I, l, L, f or d)
>>> print(array.__doc__)
This module defines an object type which can efficiently represent
an array of basic values: characters, integers, floating point
numbers.  Arrays are sequence types and behave very much like lists,
except that the type of objects stored in them is constrained.  The
type is specified at object creation time by using a type code, which
is a single character.  The following type codes are defined:

    Type code   C Type             Minimum size in bytes 
    'b'         signed integer     1 
    'B'         unsigned integer   1 
    'u'         Unicode character  2 (see note) 
    'h'         signed integer     2 
    'H'         unsigned integer   2 
    'i'         signed integer     2 
    'I'         unsigned integer   2 
    'w'         unicode character  4 
    'l'         signed integer     4 
    'L'         unsigned integer   4 
    'f'         floating point     4 
    'd'         floating point     8 

NOTE: The 'u' typecode corresponds to Python's unicode character. On 
narrow builds this is 2-bytes on wide builds this is 4-bytes.
msg90215 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-07 08:10
Apparently 'w' and 'u' were used for wide and narrow builds
respectively. In r58441 the distinction was removed and now 'u' can be
either 2 or 4 bytes, depending on the build.
I think that 'w' can be removed.
msg90217 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-07 08:34
The problem seems to affect Python 2 too. See also #1268.
In the online doc 'w' is not mentioned but a note about the size of 'u'
that changes depending on the build should be added too.
Also in the table in the Python 2 doc [1] the "Python Type" for
'unsigned int' and 'signed long' seem swapped [2].

[1]: http://docs.python.org/library/array.html
[2]: Modules/arraymodule.c under "/* Description of types */"
msg90412 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-07-11 10:39
OK, fixed this in r73940, r73941, r73942.
History
Date User Action Args
2009-07-11 10:39:31georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg90412
2009-07-07 08:34:58ezio.melottisetmessages: + msg90217
2009-07-07 08:10:12ezio.melottisetnosy: + ezio.melotti
messages: + msg90215
2009-07-06 20:40:25alexandre.vassalotticreate