Bug report
Bug description:
(This is not an asyncio bug! I am just using asyncio.TaskGroup() as an example.)
import asyncio
def foo():
with asyncio.TaskGroup() as g: # BUG: should be `async with`
pass
This currently gives an error ending in
TypeError: 'TaskGroup' object does not support the context manager protocol (missed __exit__ method)
That's not very clear about what's wrong. Maybe when issuing this TypeError we could check if the object supports __aexit__ and __aenter__, and if so, suggest something like "maybe try async with ?".
CPython versions tested on:
3.12, 3.13, 3.14
Operating systems tested on:
No response
Linked PRs
Reactions are currently unavailable
Bug report
Bug description:
(This is not an asyncio bug! I am just using asyncio.TaskGroup() as an example.)
This currently gives an error ending in
That's not very clear about what's wrong. Maybe when issuing this TypeError we could check if the object supports __aexit__ and __aenter__, and if so, suggest something like "maybe try async with ?".
CPython versions tested on:
3.12, 3.13, 3.14
Operating systems tested on:
No response
Linked PRs