mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Validate that __length_hint__ returns a usable result.
This commit is contained in:
parent
94a45da6be
commit
5d65412d35
2 changed files with 11 additions and 1 deletions
|
|
@ -105,7 +105,7 @@ _PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
|
|||
PyErr_Clear();
|
||||
return defaultvalue;
|
||||
}
|
||||
rv = PyLong_AsSsize_t(ro);
|
||||
rv = PyLong_Check(ro) ? PyLong_AsSsize_t(ro) : defaultvalue;
|
||||
Py_DECREF(ro);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue