Skip to content

asyncio.capture_call_graph: AttributeError walking async-generator ag_await chain #148736

Closed

Description

@rajkripal

In Lib/asyncio/graph.py, _build_graph_for_future uses coro.cr_frame in the ag_await branch:

elif hasattr(coro, 'ag_await'):
    st.append(FrameCallGraphEntry(coro.cr_frame))
    coro = coro.ag_await

Async generators expose ag_frame, not cr_frame, so this raises AttributeError whenever the walk reaches it. The standard async for path routes through async_generator_asend objects which have neither attribute, so the walker hits the else: break first — which is why the test suite doesn't catch it. A coroutine whose cr_await chains directly to an async-generator-shaped object (duck-typed or manually driven) trips the bug.

Introduced in 1885988 (Jan 2025).

Linked PRs

Activity

  1. added a commit that references this issue on Apr 18, 2026
  2. added
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    on Apr 18, 2026
  3. added a commit that references this issue on Apr 18, 2026
  4. added a commit that references this issue on Jul 26, 2026
  5. moved this from Todo to Done in asyncioon Jul 26, 2026
  6. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or error

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions