FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.14] GH-135171: Fix generator expressions one last time (hopefully) by markshannon · Pull Request #135225 · python/cpython · GitHub

Repository navigation

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

Merged
markshannon merged 6 commits into
python:3.14from
faster-cpython:fix-gen-expr-yet-again
Jun 9, 2025
Merged

markshannon merged 6 commits into
python:3.14from
faster-cpython:fix-gen-expr-yet-again

Conversation

markshannon commented Jun 6, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

Please restore also old tests.

I think this change should be made in main.

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Member

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

efimov-mikhail 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

bedevere-app Bot commented Jun 9, 2025

Copy link
Copy Markdown

GH-135293 is a backport of this pull request to the 3.13 branch.

Comment thread Lib/test/test_dis.py
@@ -204,6 +204,7 @@ def bug1333982(x=[]):
LOAD_CONST 1 (<code object <genexpr> at 0x..., file "%s", line %d>)
MAKE_FUNCTION
LOAD_FAST_BORROW 0 (x)

This comment was marked as spam.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

4 participants


Back | FazBrowse Home | New Git URL