Skip to content

Outdated error message when passing an invalid typecode to array.array constructor #132527

Closed
@tomasr8

Description

@tomasr8

Bug report

Bug description:

This issue is suitable for a first-time contributor.

The 'w' typecode is supported but the error message does not mention it:

>>> array('x')
Traceback (most recent call last):
  File "<python-input-5>", line 1, in <module>
    array('x')
    ~~~~~^^^^^
ValueError: bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f or d)

We should add 'w' to the list. This is the relevant part of the code that should be updated:

cpython/Modules/arraymodule.c

Lines 2875 to 2877 in 6163841

PyErr_SetString(PyExc_ValueError,
"bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f or d)");
return NULL;

Happy to help if you have any questions!

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixeseasyextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions