summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-06-01 05:22:55 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-06-01 05:22:55 (GMT)
commit93b2cc4e974121ac1f7f705b3a3dbec7a2e944ab (patch)
treed0f031e1e83b4af917d43a93baa8b6dcdd36f94b
parentbb98c8cff0987e9c1afbc1967721ff4999c5d381 (diff)
downloadcpython-93b2cc4e974121ac1f7f705b3a3dbec7a2e944ab.zip
cpython-93b2cc4e974121ac1f7f705b3a3dbec7a2e944ab.tar.gz
cpython-93b2cc4e974121ac1f7f705b3a3dbec7a2e944ab.tar.bz2
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.
-rw-r--r--Objects/listobject.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index c2892c6..bd391af 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -1819,8 +1819,8 @@ static PyTypeObject immutable_list_type = {
typedef struct {
PyObject_HEAD
- long it_index;
- PyObject *it_seq;
+ long it_index;
+ PyListObject *it_seq;
} listiterobject;
PyTypeObject PyListIter_Type;
@@ -1839,7 +1839,7 @@ list_iter(PyObject *seq)
return NULL;
it->it_index = 0;
Py_INCREF(seq);
- it->it_seq = seq;
+ it->it_seq = (PyListObject *)seq;
_PyObject_GC_TRACK(it);
return (PyObject *)it;
}
@@ -1855,7 +1855,7 @@ listiter_dealloc(listiterobject *it)
static int
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 *
-listiter_next(PyObject *it)
+listiter_next(listiterobject *it)
{
- PyObject *seq;
+ PyListObject *seq;
PyObject *item;
- assert(PyList_Check(it));
- seq = ((listiterobject *)it)->it_seq;
+ assert(it != NULL);
+ seq = it->it_seq;
+ assert(PyList_Check(seq));
- if (((listiterobject *)it)->it_index < PyList_GET_SIZE(seq)) {
- item = ((PyListObject *)(seq))->ob_item[((listiterobject *)it)->it_index++];
+ if (it->it_index < PyList_GET_SIZE(seq)) {
+ item = PyList_GET_ITEM(seq, it->it_index);
+ ++it->it_index;
Py_INCREF(item);
return item;
}