-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-129013: Don't expose async_generator_wrapped_value
in PY_YIELD
callbacks
#129031
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
1ac565b
0e47178
d36fbef
3b3ba51
0b60959
51c0fd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2083,6 +2083,30 @@ def callback(code, instruction_offset): | |||||||||||||
sys.monitoring.restart_events() | ||||||||||||||
sys.monitoring.set_events(0, 0) | ||||||||||||||
|
||||||||||||||
@test.support.requires_working_socket() # For asyncio | ||||||||||||||
def test_yield_async_generator(self): | ||||||||||||||
# gh-129013: Async generators have a special type that they | ||||||||||||||
# use to yield values. This type shouldn't be exposed by PY_YIELD | ||||||||||||||
# events. | ||||||||||||||
asyncio = test.support.import_helper.import_module("asyncio") | ||||||||||||||
|
||||||||||||||
async def gen(): | ||||||||||||||
yield 42 | ||||||||||||||
|
||||||||||||||
async def main(): | ||||||||||||||
async for _ in gen(): | ||||||||||||||
pass | ||||||||||||||
|
||||||||||||||
def handle_yield(code, offset, value): | ||||||||||||||
self.assertEqual(value, 42) | ||||||||||||||
|
||||||||||||||
sys.monitoring.use_tool_id(0, "test") | ||||||||||||||
sys.monitoring.register_callback(0, sys.monitoring.events.PY_YIELD, handle_yield) | ||||||||||||||
sys.monitoring.set_events(0, sys.monitoring.events.PY_YIELD) | ||||||||||||||
|
||||||||||||||
asyncio.run(main()) | ||||||||||||||
sys.monitoring.set_events(0, 0) | ||||||||||||||
Comment on lines
+2181
to
+2182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would seem slightly cleaner.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not disagreeing, but I'd rather stay consistent with the rest of the file. |
||||||||||||||
|
||||||||||||||
|
||||||||||||||
class TestOptimizer(MonitoringTestBase, unittest.TestCase): | ||||||||||||||
|
||||||||||||||
|
@@ -2329,3 +2353,6 @@ def test_enter_scope_two_events(self): | |||||||||||||
|
||||||||||||||
finally: | ||||||||||||||
sys.monitoring.set_events(TEST_TOOL, 0) | ||||||||||||||
|
||||||||||||||
if __name__ == "__main__": | ||||||||||||||
unittest.main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix odd/unusable value when using :monitoring-event:`PY_YIELD` with an | ||
:term:`asynchronous generator`. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.