Skip to content

gh-149313: Preserve exception notes/cause in dict/set unhashable type…#149505

Open
anujbharambe wants to merge 2 commits intopython:mainfrom
anujbharambe:fix-unhashable-exception-chaining
Open

gh-149313: Preserve exception notes/cause in dict/set unhashable type…#149505
anujbharambe wants to merge 2 commits intopython:mainfrom
anujbharambe:fix-unhashable-exception-chaining

Conversation

@anujbharambe
Copy link
Copy Markdown
Contributor

@anujbharambe anujbharambe commented May 7, 2026

Summary

Chain the original TypeError as __cause__ and __context__ on the new exception in dict_unhashable_type() and set_unhashable_type(). This preserves __notes__, __traceback__, and any existing cause chain that were previously discarded when the improved error message was created.

Fixes #149313
Some parts of this PR were written with the assistance of Claude (AI).

@StanFromIreland
Copy link
Copy Markdown
Member

Updating to fix some errors we introduced on the main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception notes discarded from TypeError within __hash__()

3 participants