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

Merged
merged 6 commits into from
Jun 9, 2025

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.

@markshannon markshannon merged commit a5274cd into python:3.14 Jun 9, 2025
64 checks passed
@miss-islington-app
Copy link

Thanks @markshannon for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

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

cherry_picker a5274cd2158a0c7eaa6f54b4e74f8b4e92195e5e 3.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport to 3.13 bugs and security fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants