8000 Improve the error message for invalid typecodes in `multiprocessing.{Array,Value}` · Issue #133017 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Improve the error message for invalid typecodes in multiprocessing.{Array,Value} #133017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tomasr8 opened this issue Apr 26, 2025 · 0 comments
Closed
Assignees
Labels
stdlib Python modules in the Lib dir topic-multiprocessing type-feature A feature request or enhancement

Comments

@tomasr8
Copy link
Member
tomasr8 commented Apr 26, 2025

Feature or enhancement

Proposal:

More discussion: #132504 (comment)

This is the current message which is not very clear (it comes from ctypes.sizeof):

>>> from multiprocessing import Array
>>> Array('x', 1)
...
TypeError: this type has no size

I propose we change it to:

>>> from multiprocessing import Array
>>> Array('x', 1)
TypeError: bad typecode (must be a ctypes type or one of c, b, B, u, h, H, i, I, l, L, q, Q, f or d)

This is modeled after the error message in array.array which is more informative:

>>> array('x')
...
ValueError: bad typecode (must be b, B, u, w, h, H, i, I, l, L, q, Q, f or d)

(A ValueError seems like a more appropriate option for multiprocessing as well, but that'd be a breaking change)
Note that, multiprocessing.Array (and Value) does not support the 'w' typecode while array.array does.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

#132504 (comment)

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-multiprocessing type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants
0