Skip to content

gh-158380: Fix the stack operand used by JIT dict access guards - #158381

Merged
markshannon merged 2 commits into
python:mainfrom
cocolato:bug/dict_guard
Sep 30, 2026
Merged

markshannon merged 2 commits into
python:mainfrom
cocolato:bug/dict_guard

Conversation

@cocolato

@cocolato cocolato commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

The probable type branches of _GUARD_NOS_DICT_SUBSCRIPT and _GUARD_NOS_DICT_STORE_SUBSCRIPT now check the dict at NOS:

Stack (top on the right):
  Read:  ... mapping, key
  Write: ... value, mapping, key

Before: _GUARD_TYPE     checks type(key)     == expected_type
After:  _GUARD_NOS_TYPE checks type(mapping) == expected_type

Reuse the existing NOS guard by renaming _GUARD_TYPE_ITER to _GUARD_NOS_TYPE, update its iterator call site, and regenerate the affected files fix this issue. Known-type paths still omit the guard.

@cocolato cocolato added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 30, 2026

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, thanks.

@markshannon
markshannon merged commit b98c065 into python:main Sep 30, 2026
89 of 90 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @cocolato for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @cocolato and @markshannon, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker b98c065756ea336707c30885831e4afcb85aac84 3.15

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

Labels

needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants