sys.monitoring `PY_YIELD` leaks internal `async_generator_wrapped_value` object
オープン
まだ誰も着手していません。
interpreter-core
type-feature
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
Rather than the actual value, sys.monitoring's PY_YIELD event passes in to the callback the internal async_generator_wrapped_value.
I imagine this is a bug... it's inconsistent with what it does for non-async generators.
import sys
import types
import typing
import asyncio
async def gen():
yield 42
async def main():
async for _ in gen():
pass
def handle_yield(code: types.CodeType, offset: int, value: object) -> typing.Any:
if code.co_filename == __file__:
print(f"yield name={code.co_qualname} {type(value)=}")
sysmon = sys.monitoring
sysmon.use_tool_id(4, "r")
sysmon.register_callback(4, sysmon.events.PY_YIELD, handle_yield)
sysmon.set_events(4, sysmon.events.PY_YIELD)
asyncio.run(main())
This prints out:
yield name=gen type(value)=<class 'async_generator_wrapped_value'>
CPython versions tested on:
3.12, 3.13, 3.14
Operating systems tested on:
macOS, Linux
Linked PRs
- gh-129031
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供されている sys.monitoring PY_YIELD の再現手順を影響を受ける CPython バージョンで実行し、async generators に対する callback の動作を確認してください。現在の実装方針について、リンクされている PR gh-129031 を確認してください。このケースのテストカバレッジがあり、callback が内部の async_generator_wrapped_value オブジェクトではなく yielded value を受け取るようになれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100