mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-29838: Add asserts for checking results of sq_length and mq_length slots. (#700)
Negative result should be returned only when an error is set.
This commit is contained in:
parent
026435ce49
commit
813f943c59
3 changed files with 29 additions and 11 deletions
|
|
@ -5427,8 +5427,10 @@ getindex(PyObject *self, PyObject *arg)
|
|||
PySequenceMethods *sq = Py_TYPE(self)->tp_as_sequence;
|
||||
if (sq && sq->sq_length) {
|
||||
Py_ssize_t n = (*sq->sq_length)(self);
|
||||
if (n < 0)
|
||||
if (n < 0) {
|
||||
assert(PyErr_Occurred());
|
||||
return -1;
|
||||
}
|
||||
i += n;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue