mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
GH-141312: Allow only integers to longrangeiter_setstate state (GH-141317)
This fixes an assertion error when the new computed start is not an integer.
This commit is contained in:
parent
49e74210cb
commit
10bec7c1eb
3 changed files with 17 additions and 0 deletions
|
|
@ -1042,6 +1042,11 @@ longrangeiter_reduce(PyObject *op, PyObject *Py_UNUSED(ignored))
|
|||
static PyObject *
|
||||
longrangeiter_setstate(PyObject *op, PyObject *state)
|
||||
{
|
||||
if (!PyLong_CheckExact(state)) {
|
||||
PyErr_Format(PyExc_TypeError, "state must be an int, not %T", state);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
longrangeiterobject *r = (longrangeiterobject*)op;
|
||||
PyObject *zero = _PyLong_GetZero(); // borrowed reference
|
||||
int cmp;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue