mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #16402: In range slicing, fix shadowing of exceptions from __index__ method.
This commit is contained in:
parent
b87f82f8d4
commit
8cd1c7681d
3 changed files with 17 additions and 5 deletions
|
@ -330,11 +330,11 @@ compute_slice_element(PyObject *obj)
|
|||
if (PyIndex_Check(obj)) {
|
||||
result = PyNumber_Index(obj);
|
||||
}
|
||||
}
|
||||
if (result == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"slice indices must be integers or "
|
||||
"None or have an __index__ method");
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"slice indices must be integers or "
|
||||
"None or have an __index__ method");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue