diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-06-23 18:47:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-23 18:47:47 (GMT) |
commit | d8ca5a11bc55e2a69cab4f8795d0a5aa6932a41b (patch) | |
tree | aef00ea1df35757252351d4c1fd39152026e86b5 /Objects | |
parent | 1d33d5378058671bfabb6f4d4b5bfd4726973ff9 (diff) | |
download | cpython-d8ca5a11bc55e2a69cab4f8795d0a5aa6932a41b.zip cpython-d8ca5a11bc55e2a69cab4f8795d0a5aa6932a41b.tar.gz cpython-d8ca5a11bc55e2a69cab4f8795d0a5aa6932a41b.tar.bz2 |
gh-105730: support more callables in ExceptionGroup.split() and subgroup() (#106035)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/exceptions.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 04ea22c..f27e6f6 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -992,7 +992,7 @@ get_matcher_type(PyObject *value, { assert(value); - if (PyFunction_Check(value)) { + if (PyCallable_Check(value) && !PyType_Check(value)) { *type = EXCEPTION_GROUP_MATCH_BY_PREDICATE; return 0; } @@ -1016,7 +1016,7 @@ get_matcher_type(PyObject *value, error: PyErr_SetString( PyExc_TypeError, - "expected a function, exception type or tuple of exception types"); + "expected an exception type, a tuple of exception types, or a callable (other than a class)"); return -1; } @@ -1032,7 +1032,7 @@ exceptiongroup_split_check_match(PyObject *exc, return PyErr_GivenExceptionMatches(exc, matcher_value); } case EXCEPTION_GROUP_MATCH_BY_PREDICATE: { - assert(PyFunction_Check(matcher_value)); + assert(PyCallable_Check(matcher_value) && !PyType_Check(matcher_value)); PyObject *exc_matches = PyObject_CallOneArg(matcher_value, exc); if (exc_matches == NULL) { return -1; |