summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-06-23 18:47:47 (GMT)
committerGitHub <noreply@github.com>2023-06-23 18:47:47 (GMT)
commitd8ca5a11bc55e2a69cab4f8795d0a5aa6932a41b (patch)
treeaef00ea1df35757252351d4c1fd39152026e86b5 /Doc/library
parent1d33d5378058671bfabb6f4d4b5bfd4726973ff9 (diff)
downloadcpython-d8ca5a11bc55e2a69cab4f8795d0a5aa6932a41b.zip
cpython-d8ca5a11bc55e2a69cab4f8795d0a5aa6932a41b.tar.gz
cpython-d8ca5a11bc55e2a69cab4f8795d0a5aa6932a41b.tar.bz2
gh-105730: support more callables in ExceptionGroup.split() and subgroup() (#106035)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/exceptions.rst12
1 files changed, 8 insertions, 4 deletions
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 4c84e5f..8e574b8 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -912,10 +912,11 @@ their subgroups based on the types of the contained exceptions.
Returns an exception group that contains only the exceptions from the
current group that match *condition*, or ``None`` if the result is empty.
- The condition can be either a function that accepts an exception and returns
- true for those that should be in the subgroup, or it can be an exception type
- or a tuple of exception types, which is used to check for a match using the
- same check that is used in an ``except`` clause.
+ The condition can be an exception type or tuple of exception types, in which
+ case each exception is checked for a match using the same check that is used
+ in an ``except`` clause. The condition can also be a callable (other than
+ a type object) that accepts an exception as its single argument and returns
+ true for the exceptions that should be in the subgroup.
The nesting structure of the current exception is preserved in the result,
as are the values of its :attr:`message`, :attr:`__traceback__`,
@@ -926,6 +927,9 @@ their subgroups based on the types of the contained exceptions.
including the top-level and any nested exception groups. If the condition is
true for such an exception group, it is included in the result in full.
+ .. versionadded:: 3.13
+ ``condition`` can be any callable which is not a type object.
+
.. method:: split(condition)
Like :meth:`subgroup`, but returns the pair ``(match, rest)`` where ``match``