◐ Shell
reader mode source ↗
Skip to content

gh-145876: Do not mask AttributeErrors raised during dictionary unpacking#145906

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:unpack-dict-pass-errors
Mar 26, 2026
Merged

gh-145876: Do not mask AttributeErrors raised during dictionary unpacking#145906
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:unpack-dict-pass-errors

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Mar 13, 2026

Copy link
Copy Markdown
Member

AttributeErrors raised in keys() or __getitem__() during dictionary unpacking ({**mymapping} or func(**mymapping)) are no longer masked by TypeError.

… unpacking

AttributeErrors raised in keys() or __getitem__() during
dictionary unpacking ({**mymapping} or func(**mymapping)) are
no longer masked by TypeError.

@NickCrews NickCrews left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

The tests look good to me, modulo my question about checking for error chaining.

I wanted to point out non-atomic way we are checking for the presence of .keys(). But I'm guessing you had reasons you weren't doing something else.

Thanks for your work here!

@NickCrews

Copy link
Copy Markdown
Contributor

Thanks for the responses to my review @serhiy-storchaka. It looks like you already considered all the potential concerns I raised, and you know better than me the pros/cons of the solutions. So this looks good to me!

Is there anything I can do to help move this forward? Would a benchmark be useful to verify this doesn't hurt performance too much? Should I do that by adding a test case to the pyperformance repo, similar to this PR from 2 months ago?

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Nothing. I only waited if there are any suggestions or objections.

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) March 26, 2026 13:20
Hide details View details @serhiy-storchaka serhiy-storchaka merged commit 0e54305 into python:main Mar 26, 2026
76 checks passed
@serhiy-storchaka serhiy-storchaka deleted the unpack-dict-pass-errors branch March 26, 2026 15:12
@NickCrews

Copy link
Copy Markdown
Contributor

Thank you!

clin1234 pushed a commit to clin1234/cpython that referenced this pull request Apr 16, 2026
… unpacking (pythonGH-145906)

AttributeErrors raised in keys() or __getitem__() during
dictionary unpacking ({**mymapping} or func(**mymapping)) are
no longer masked by TypeError.
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
… unpacking (pythonGH-145906)

AttributeErrors raised in keys() or __getitem__() during
dictionary unpacking ({**mymapping} or func(**mymapping)) are
no longer masked by TypeError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants