Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Wrong exception re-raises if task raises CancelledError inside except block #287

@germn

Description

@germn
import asyncio
from contextlib import suppress


async def main():
    task = asyncio.ensure_future(asyncio.sleep(1))
    task.cancel()

    try:
        raise Exception()
    except Exception:
        with suppress(asyncio.CancelledError):
            await task
        raise

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Expected output:

Exception

Actual output:

concurrent.futures._base.CancelledError

Windows 10, Python 3.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions