diff --git a/Lib/asyncio/timeouts.py b/Lib/asyncio/timeouts.py index 09342dc7c1310b..dff70354e42cd8 100644 --- a/Lib/asyncio/timeouts.py +++ b/Lib/asyncio/timeouts.py @@ -114,7 +114,7 @@ async def __aexit__( raise TimeoutError from exc_val elif exc_val is not None: self._insert_timeout_error(exc_val) - if isinstance(exc_val, ExceptionGroup): + if isinstance(exc_val, BaseExceptionGroup): for exc in exc_val.exceptions: self._insert_timeout_error(exc) elif self._state is _State.ENTERED: diff --git a/Misc/NEWS.d/next/Library/2025-08-15-14-12-29.gh-issue-137549.2DaXja.rst b/Misc/NEWS.d/next/Library/2025-08-15-14-12-29.gh-issue-137549.2DaXja.rst new file mode 100644 index 00000000000000..859b99f63e7893 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-08-15-14-12-29.gh-issue-137549.2DaXja.rst @@ -0,0 +1,2 @@ +Modify ``__aexit__`` method of ``asyncio.Timeout`` class to handle the superclass of ExceptionGroup object. +Patch by gunyu1019.