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:
Serhiy Storchaka 2017-04-16 09:21:44 +03:00 committed by GitHub
parent 026435ce49
commit 813f943c59
3 changed files with 29 additions and 11 deletions

View file

@ -1479,8 +1479,10 @@ builtin_len(PyObject *module, PyObject *obj)
Py_ssize_t res;
res = PyObject_Size(obj);
if (res < 0 && PyErr_Occurred())
if (res < 0) {
assert(PyErr_Occurred());
return NULL;
}
return PyLong_FromSsize_t(res);
}