Skip to content

[3.15] gh-154902: Type-check the SET_ADD operand - #155071

Open
deadlovelll wants to merge 3 commits into
python:3.15from
deadlovelll:gh-154902-rebind-check
Open

[3.15] gh-154902: Type-check the SET_ADD operand#155071
deadlovelll wants to merge 3 commits into
python:3.15from
deadlovelll:gh-154902-rebind-check

Conversation

@deadlovelll

@deadlovelll deadlovelll commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Type-check the SET_ADD operand

This is an alternative version of fix for #154902, but dedicated to 3.15 and 3.14 only, because we cant change bytecode here

@deadlovelll deadlovelll changed the title gh-154902: Type-check the SET_ADD operand [3.15] gh-154902: Type-check the SET_ADD operand Aug 2, 2026
@deadlovelll

Copy link
Copy Markdown
Contributor Author

Looked at the checks, I think these are flakes. Could someone with the rights rerun the failed jobs?

Comment thread Python/bytecodes.c Outdated
// gh-154902: user code can rebind __conditional_annotations__
if (!PySet_Check(set_o)) {
_PyErr_Format(tstate, PyExc_TypeError,
"__conditional_annotations__ must be a set, not %T",

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.

Error message shouldn't mention __conditional_annotations__ as this is a generic opcode (though probably the only way this is reachable is through __conditional_annotations__).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed

Comment thread Python/bytecodes.c Outdated
int err = _PySet_AddTakeRef((PySetObject *)PyStackRef_AsPyObjectBorrow(set),
PyObject *set_o = PyStackRef_AsPyObjectBorrow(set);
// gh-154902: user code can rebind __conditional_annotations__
if (!PySet_Check(set_o)) {

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.

Thoughts on whether this should be CheckExact?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

missed that it applies here too , changed to CheckExact

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.

2 participants