Skip to content

asyncio: initial exception traceback frames are lost for Future.result() #154791

Closed

Description

@iaroslavkrasikov

Since gh-90082 (PR #30274), the C implementation of Future stores it's exception and traceback separately. However, Future.result() clears the traceback after first call, which means the initial traceback frames are lost on subsequent awaits or result() calls. Pure-python Future implementation is unaffected.

async def fail():
    await asyncio.sleep(0.1)
    1 / 0

async def main():
    task = asyncio.create_task(fail())
    await asyncio.sleep(0.2)
    with contextlib.suppress(ZeroDivisionError):
        await task
    await task

_CFuture traceback (current):

Traceback (most recent call last):
  ...
  File "<python-input-0>", line 9, in main
    await task
ZeroDivisionError

_PyFuture traceback (expected):

Traceback (most recent call last):
  ...
  File "<python-input-7>", line 9, in main
    await task
  ...
  File "<python-input-7>", line 3, in fail
    1 / 0
ZeroDivisionError

Linked PRs

Activity

  1. changed the title [-]asyncio: inital exception traceback frames are lost for Future.result()[/-] [+]asyncio: initial exception traceback frames are lost for Future.result()[/+] on Jul 27, 2026
  2. added a commit that references this issue on Jul 28, 2026
  3. added a commit that references this issue on Jul 31, 2026
  4. moved this from Todo to Done in asyncioon Jul 31, 2026
  5. 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

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions