mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +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
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue