Skip to content
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

Backport changes to contextlib.suppress()? #91

Closed
Zac-HD opened this issue Nov 8, 2023 · 4 comments · Fixed by #95
Closed

Backport changes to contextlib.suppress()? #91

Zac-HD opened this issue Nov 8, 2023 · 4 comments · Fixed by #95
Labels
enhancement New feature or request

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented Nov 8, 2023

python/cpython#103792 modified contextlib.suppress() to support ExceptionGroups, by removing suppressed exceptions. If there are no remaining exceptions in the group it's caught; otherwise the remainder is re-raised.

It seems useful to provide this behavior to exceptiongroup users on Python < 3.12 (notably including 3.11, where ExceptionGroup is built in but suppress() did not handle it).

@Zac-HD Zac-HD added the enhancement New feature or request label Nov 8, 2023
@agronholm
Copy link
Owner

I wonder if BaseExceptionGroup was intentionally not supported there.

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Nov 9, 2023

Irit thinks it was an accident, so I'll have a PR up against CPython shortly. e: python/cpython#111910

@agronholm
Copy link
Owner

Yep, I figured as much :)

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Nov 15, 2023

PR merged, will ship in Python 3.12.1 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants