mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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:
parent
4901ea9526
commit
cafe1b6e9d
4 changed files with 21 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue