Commit 7660b880 authored by Victor Stinner's avatar Victor Stinner

Issue #9566: More long/Py_ssize_t fixes in tuple and list iterators (it_index)

parent 9a644b23
...@@ -2660,7 +2660,7 @@ PyTypeObject PyList_Type = { ...@@ -2660,7 +2660,7 @@ PyTypeObject PyList_Type = {
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
long it_index; Py_ssize_t it_index;
PyListObject *it_seq; /* Set to NULL when iterator is exhausted */ PyListObject *it_seq; /* Set to NULL when iterator is exhausted */
} listiterobject; } listiterobject;
...@@ -2797,7 +2797,7 @@ listiter_reduce(listiterobject *it) ...@@ -2797,7 +2797,7 @@ listiter_reduce(listiterobject *it)
static PyObject * static PyObject *
listiter_setstate(listiterobject *it, PyObject *state) listiter_setstate(listiterobject *it, PyObject *state)
{ {
long index = PyLong_AsLong(state); Py_ssize_t index = PyLong_AsSsize_t(state);
if (index == -1 && PyErr_Occurred()) if (index == -1 && PyErr_Occurred())
return NULL; return NULL;
if (it->it_seq != NULL) { if (it->it_seq != NULL) {
...@@ -2958,7 +2958,7 @@ listiter_reduce_general(void *_it, int forward) ...@@ -2958,7 +2958,7 @@ listiter_reduce_general(void *_it, int forward)
if (forward) { if (forward) {
listiterobject *it = (listiterobject *)_it; listiterobject *it = (listiterobject *)_it;
if (it->it_seq) if (it->it_seq)
return Py_BuildValue("N(O)l", _PyObject_GetBuiltin("iter"), return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
it->it_seq, it->it_index); it->it_seq, it->it_index);
} else { } else {
listreviterobject *it = (listreviterobject *)_it; listreviterobject *it = (listreviterobject *)_it;
......
...@@ -988,7 +988,7 @@ static PyObject * ...@@ -988,7 +988,7 @@ static PyObject *
tupleiter_reduce(tupleiterobject *it) tupleiter_reduce(tupleiterobject *it)
{ {
if (it->it_seq) if (it->it_seq)
return Py_BuildValue("N(O)l", _PyObject_GetBuiltin("iter"), return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
it->it_seq, it->it_index); it->it_seq, it->it_index);
else else
return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter")); return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter"));
...@@ -997,7 +997,7 @@ tupleiter_reduce(tupleiterobject *it) ...@@ -997,7 +997,7 @@ tupleiter_reduce(tupleiterobject *it)
static PyObject * static PyObject *
tupleiter_setstate(tupleiterobject *it, PyObject *state) tupleiter_setstate(tupleiterobject *it, PyObject *state)
{ {
Py_ssize_t index = PyLong_AsLong(state); Py_ssize_t index = PyLong_AsSsize_t(state);
if (index == -1 && PyErr_Occurred()) if (index == -1 && PyErr_Occurred())
return NULL; return NULL;
if (it->it_seq != NULL) { if (it->it_seq != NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment