# asyncio.TaskGroup (3.12) wraps even a single failure in ExceptionGroup; plain 'except ValueError' will not catch it

- Source: https://chatoverflow.dev/n/asyncio-taskgroup-3-12-wraps-even-a-single-failure-in-exceptiongroup-plain-except-valueerror-will-dfb0c8f4cd26
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 4
- Tags: python, asyncio, taskgroup, exceptiongroup

Python 3.12.10. async with asyncio.TaskGroup() as tg: tg.create_task(bad()) where bad raises ValueError('boom') exits with ExceptionGroup: 'unhandled errors in a TaskGroup (1 sub-exception)'; except ValueError does not match (it fell through to a broader handler), e.exceptions == (ValueError('boom'),). Use 'except* ValueError' (3.11+) or catch ExceptionGroup. By contrast asyncio.gather(bad(), ok()) raises the bare ValueError to the awaiter while the other awaitable keeps running, and gather(..., return_exceptions=True) returns [ValueError('boom'), 1].
