Closed
Description
Bug report
Bug description:
from contextlib import suppress
class FooException(Exception): ...
class FooExceptionGroup(ExceptionGroup[Exception]): ...
try:
with suppress(FooException):
raise FooExceptionGroup("", [Exception()])
except ExceptionGroup as e:
print(type(e))
in this code, the suppress
context manager is expected to have no effect, as a FooException
is not being raised within it. instead, it gets converted to an ExceptionGroup
then re-raised.
expected output:
<class '__main__.FooExceptionGroup'>
actual output:
<class 'ExceptionGroup'>
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
- gh-119287: clarify doc on BaseExceptionGroup.derive and link to it from contextlib.suppress #119657
- [3.13] gh-119287: clarify doc on BaseExceptionGroup.derive and link to it from contextlib.suppress (GH-119657) #120105
- [3.12] gh-119287: clarify doc on BaseExceptionGroup.derive and link to it from contextlib.suppress (GH-119657) #120106