Skip to content

gh-148675: Reuse typecodes for array.array() error message#149779

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:array_errmsg
May 15, 2026
Merged

gh-148675: Reuse typecodes for array.array() error message#149779
vstinner merged 1 commit into
python:mainfrom
vstinner:array_errmsg

Conversation

@vstinner
Copy link
Copy Markdown
Member

@vstinner vstinner commented May 13, 2026

array.array() error message now reuses array.typecodes, instead of maintaining an hardcoded list of valid type codes.

array.array() error message now reuses array.typecodes, instead of
maintaining an hardcoded list of valid type codes.
@vstinner
Copy link
Copy Markdown
Member Author

Example:

import array
array.array('v')

Output:

Traceback (most recent call last):
  File "/home/vstinner/python/main/x.py", line 2, in <module>
    array.array('v')
    ~~~~~~~~~~~^^^^^
ValueError: bad typecode (must be: b, B, u, w, h, H, i, I, l, L, q, Q, e, f, d, Zf, Zd)

@vstinner vstinner merged commit a8ef467 into python:main May 15, 2026
56 checks passed
@vstinner vstinner deleted the array_errmsg branch May 15, 2026 11:22
@vstinner
Copy link
Copy Markdown
Member Author

Merged, thanks for the review.

I wrote this change since recently, I noticed that 3 type codes were missing from this error message. I fixed the error message, but with this change it's no longer neeeded (it's always up to date).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants