Skip to content

{}.pop([]) raises KeyError not TypeError - only on empty dict #142396

@samuelcolvin

Description

@samuelcolvin

Bug report

Bug description:

{}.pop([])

Raises a KeyError, not a TypeError as I would expect.

However

{1: 2}.pop([])

Raises TypeError: cannot use 'list' as a dict key (unhashable type: 'list') as you'd expected.

This isn't new, it's been around since at least 3.8. Is it really intended? If so, it should be documented.

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions