A bogus assert in the new listiter code prevented starting Python in a
debug build. Repaired that, and rewrote other parts to reduce long-winded casting.
This commit is contained in:
parent
bb98c8cff0
commit
93b2cc4e97
@ -1819,8 +1819,8 @@ static PyTypeObject immutable_list_type = {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
long it_index;
|
long it_index;
|
||||||
PyObject *it_seq;
|
PyListObject *it_seq;
|
||||||
} listiterobject;
|
} listiterobject;
|
||||||
|
|
||||||
PyTypeObject PyListIter_Type;
|
PyTypeObject PyListIter_Type;
|
||||||
@ -1839,7 +1839,7 @@ list_iter(PyObject *seq)
|
|||||||
return NULL;
|
return NULL;
|
||||||
it->it_index = 0;
|
it->it_index = 0;
|
||||||
Py_INCREF(seq);
|
Py_INCREF(seq);
|
||||||
it->it_seq = seq;
|
it->it_seq = (PyListObject *)seq;
|
||||||
_PyObject_GC_TRACK(it);
|
_PyObject_GC_TRACK(it);
|
||||||
return (PyObject *)it;
|
return (PyObject *)it;
|
||||||
}
|
}
|
||||||
@ -1855,7 +1855,7 @@ listiter_dealloc(listiterobject *it)
|
|||||||
static int
|
static int
|
||||||
listiter_traverse(listiterobject *it, visitproc visit, void *arg)
|
listiter_traverse(listiterobject *it, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
return visit(it->it_seq, arg);
|
return visit((PyObject *)it->it_seq, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1867,16 +1867,18 @@ listiter_getiter(PyObject *it)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listiter_next(PyObject *it)
|
listiter_next(listiterobject *it)
|
||||||
{
|
{
|
||||||
PyObject *seq;
|
PyListObject *seq;
|
||||||
PyObject *item;
|
PyObject *item;
|
||||||
|
|
||||||
assert(PyList_Check(it));
|
assert(it != NULL);
|
||||||
seq = ((listiterobject *)it)->it_seq;
|
seq = it->it_seq;
|
||||||
|
assert(PyList_Check(seq));
|
||||||
|
|
||||||
if (((listiterobject *)it)->it_index < PyList_GET_SIZE(seq)) {
|
if (it->it_index < PyList_GET_SIZE(seq)) {
|
||||||
item = ((PyListObject *)(seq))->ob_item[((listiterobject *)it)->it_index++];
|
item = PyList_GET_ITEM(seq, it->it_index);
|
||||||
|
++it->it_index;
|
||||||
Py_INCREF(item);
|
Py_INCREF(item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user