-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contextlib.suppress does not support ExceptionGroups #103791
Labels
type-feature
A feature request or enhancement
Comments
ambv
added a commit
that referenced
this issue
Apr 24, 2023
…ExceptionGroup (#103792) Co-authored-by: Irit Katriel <[email protected]>
carljm
added a commit
to carljm/cpython
that referenced
this issue
Apr 24, 2023
* main: pythongh-87729: add LOAD_SUPER_ATTR instruction for faster super() (python#103497) pythongh-103791: Make contextlib.suppress also act on exceptions within an ExceptionGroup (python#103792)
iritkatriel
pushed a commit
that referenced
this issue
Nov 10, 2023
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Nov 10, 2023
…)` (pythonGH-111910) (cherry picked from commit d61313b) Co-authored-by: Zac Hatfield-Dodds <[email protected]>
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
contextlib.suppress
does not successfully suppress exceptions that are wrapped within anExceptionGroup
.In other words, this works:
while this doesn't:
The user's intent is to suppress the latter case, too. It should work just as well, removing
ValueError
instances from the exception group. If it ends up empty, nothing gets raised. Otherwise, anExceptionGroup
should be re-raised with the remaining exceptions. For instance:should raise an
ExceptionGroup
with theKeyError("ke")
only, as we suppressed ValueError instances.Linked PRs
BaseExceptionGroup
incontextlib.suppress()
#111910BaseExceptionGroup
incontextlib.suppress()
(GH-111910) #111955The text was updated successfully, but these errors were encountered: