Skip to content

[3.14] GH-135171: Fix generator expressions one last time (hopefully) #135225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: 3.14
Choose a base branch
from

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Jun 6, 2025

This PR adds a NULL check for tp_iternext to FOR_ITER to prevent the crash in #125038.
It then moves GET_ITER back to generation expression creation, thus fixing #135171 and avoids re-introducing #127682 by ensuring GET_ITER is never added twice.

I've chosen to make a new PR rather than reverting earlier ones as I want to keep all the new tests we've added, and it is probably easier to review than multiple reverts.

@hugovk @Yhg1s

@serhiy-storchaka
Copy link
Member

Please restore also old tests.

I think this change should be made in main.

@markshannon
Copy link
Member Author

I'll add back the old test.

This change can't be made in main due to the the changes to the way that iteration is implemented.

@serhiy-storchaka
Copy link
Member

Then we need to rollback more changes in main. __iter__ should be called when the generator object is created.

Copy link
Contributor

@efimov-mikhail efimov-mikhail left a comment

Choose a reason for hiding this comment

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

I'm not exactly sure about changes in codegen.c, but everything else LGTM.

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.

3 participants