GeezerVison is showing github.com — GH-143493: Conform to spec for generator expressions while supporting virtual iterators by markshannon · Pull Request #143569 · python/cpython
Conversation
markshannon
commented
Jan 8, 2026
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
- Moves the
GET_ITER instruction into the generator function preamble. This means the the iterable is converted into an iterator during generator creation, as documented, but keeps it in the same code object allowing optimization.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…erators
* Moves the `GET_ITER` instruction into the generator function preamble.
This means the the iterable is converted into an iterator during generator
creation, as documented, but keeps it in the same code object allowing
optimization.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the code was changed so much since I worked with it, that I can no longer make qualified review. I can understand particular changes, but I cannot catch if something was missed. The original idea looks reasonably.
BTW, what happens when __iter__() raises StopIteration?
Is similar change needed for asynchronous generators?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
markshannon
commented
Jan 9, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
BTW, what happens when __iter__() raises StopIteration?
The exception is raised before the generator is created and the traceback shows the iterable as the location of the exception.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Is similar change needed for asynchronous generators?
I don't think asynchronous generators were ever changed, so they still have the old behavior from 3.13 and earlier.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the one nit looks good to me
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
int gen_index, int depth,
|
|
|
expr_ty elt, expr_ty val, int type,
|
|
|
int iter_on_stack)
|
|
|
IterStackState iter_on_stack)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is it worth renaming these to something like iter_state like it is in codegen_comprehension?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't it state, it is its location. Maybe I'll rename IterStackState instead.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️
Hi! The buildbot ARM64 macOS 3.x (tier-2) has failed when building commit ae53da5.
What do you need to do:
- Don't panic.
- Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
- Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/725/builds/12565) and take a look at the build logs.
- Check if the failure is related to this commit (ae53da5) or if it is a false positive.
- If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.
You can take a look at the buildbot page here:
https://buildbot.python.org/#/builders/725/builds/12565
Failed tests:
Failed subtests:
- test_call_count_thread_safe - test.test_unittest.testmock.testthreadingmock.TestThreadingMock.test_call_count_thread_safe
- test_preauth_data_to_tls_server - test.test_ssl.TestPreHandshakeClose.test_preauth_data_to_tls_server
Summary of the results of the build (if available):
==
Click to see traceback logs
Traceback (most recent call last):
File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_ssl.py", line 5476, in test_preauth_data_to_tls_server
self.assertIn("before TLS handshake with data", wrap_error.args[1])
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'before TLS handshake with data' not found in '[SSL: RECORD_LAYER_FAILURE] record layer failure (_ssl.c:1096)'
Traceback (most recent call last):
File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_unittest/testmock/testthreadingmock.py", line 219, in test_call_count_thread_safe
self.assertEqual(m.call_count, LOOPS * THREADS)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 998 != 1000
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
meta-codesync Bot
pushed a commit
to facebookincubator/cinderx
that referenced
this pull request
Jan 21, 2026
Summary: python/cpython#143569 has fixed a bug introduced in the code gen where passing a non-iterable to a generator doesn't raise immediately. This matches the code gen.
Reviewed By: mpage
Differential Revision: D90706769
fbshipit-source-id: 229a355c62e4b07ca0f3853ba91ac31b81946a8b
meta-codesync Bot
pushed a commit
to facebookincubator/cinderx
that referenced
this pull request
Jan 22, 2026
Summary:
Fixes up the CinderX build after the latest import. This brought in python/cpython#142911 which move somethings into ceval.h so that we can directly include it rather than borrowing those functions. We bring back `cinderx-only-headers` and now use them on 3.10 and 3.15+.
There's also a fix related to python/cpython#143569 where we need to update the interpreter loop.
Also python/cpython@bb25f72 seems to have refactored `_PyDict_LookupIndex` to use `_PyDict_LookupIndexAndValue`.
There's some more work after this to further reduce our usage of `ceval_macros.h` but this just gets things working again.
Reviewed By: itamaro
Differential Revision: D91146024
fbshipit-source-id: 6da3ef18fe5fe5f79e29a71cdbe98491bbb45a9d
thunder-coding
pushed a commit
to thunder-coding/cpython
that referenced
this pull request
Feb 15, 2026
…orting virtual iterators (pythonGH-143569)
* Moves the `GET_ITER` instruction into the generator function preamble.
This means the the iterable is converted into an iterator during generator
creation, as documented, but keeps it in the same code object allowing
optimization.
Reviewers
DinoV
DinoV approved these changes
iritkatriel
Awaiting requested review from iritkatriel
iritkatriel is a code owner
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|