gh-103791: Make contextlib.suppress also act on exceptions within an ExceptionGroup (#103792)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Łukasz Langa 2023-04-25 00:17:02 +02:00 committed by GitHub
parent 19e4f757de
commit 22bed58e53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 22 deletions

View file

@ -304,8 +304,15 @@ Functions and classes provided:
This context manager is :ref:`reentrant <reentrant-cms>`.
If the code within the :keyword:`!with` block raises an
:exc:`ExceptionGroup`, suppressed exceptions are removed from the
group. If any exceptions in the group are not suppressed, a group containing them is re-raised.
.. versionadded:: 3.4
.. versionchanged:: 3.12
``suppress`` now supports suppressing exceptions raised as
part of an :exc:`ExceptionGroup`.
.. function:: redirect_stdout(new_target)