bpo-40824: Do not mask errors in __iter__ in "in" and the operator module. (GH-20537)

Unexpected errors in calling the __iter__ method are no longer
masked by TypeError in the "in" operator and functions
operator.contains(), operator.indexOf() and operator.countOf().
This commit is contained in:
Serhiy Storchaka 2020-06-22 10:43:35 +03:00 committed by GitHub
parent 4901ea9526
commit cafe1b6e9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 1 deletions

View file

@ -2083,7 +2083,9 @@ _PySequence_IterSearch(PyObject *seq, PyObject *obj, int operation)
it = PyObject_GetIter(seq);
if (it == NULL) {
type_error("argument of type '%.200s' is not iterable", seq);
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
type_error("argument of type '%.200s' is not iterable", seq);
}
return -1;
}