Skip to content

KeyError hides the exception raised by str(key) #135660

Open
@Locked-chess-official

Description

@Locked-chess-official

Bug report

Bug description:

>>>a = object.__new__(type(exit))
>>>b = {}
>>>b[a]
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    b[a]
    ~^^^
KeyError: <exception str() failed>

The exception AttributeError was hidden:

Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    b[a]
    ~^^^
AttributeError: 'Quitter' object has no attribute 'name'

The exception in str() shouldn't be ignore. May because of the lack of the attribute or the wrong type that __str__ return.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions