Clarify error message when unpacking objects with `*` and `**`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
When attempting to unpack a list (or any other non-mapping) as a mapping, one gets this error message:
builtins.TypeError: 'list' object is not a mapping
It's confusing, especially since sometimes the unpacking is done on a long multi-line statement, and it's not clear that the unpacking is the source of the error.
I suggest modifying to:
builtins.TypeError: Can't unpack 'list' object using ** because it's not a mapping
I'll be happy to submit a pull request if you agree with this change.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Search CPython for the existing "object is not a mapping" error and trace the ** unpacking entry point; then add coverage for unpacking a list with ** and verify that the resulting TypeError identifies the operation and object type as requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100