Skip to content

Clarify error message when unpacking objects with * and ** #127643

@cool-RR

Description

@cool-RR

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions