`KeyError` hides the exception raised by str(key)
Open
Nobody has claimed this yet.
interpreter-core
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
Linked PRs
- gh-139961
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
Start by reproducing the b[a] example from the report on CPython 3.13 and inspect how the KeyError message calls str(key). Review linked PR gh-139961 for the current direction; done means the exception raised while formatting the key is preserved rather than hidden by the KeyError display.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100