Commit 85287cba authored by Marius Wachtler's avatar Marius Wachtler

Fix next() for reverse iter, it has to call into the reverse iter hasnext

parent 97d43471
......@@ -91,7 +91,13 @@ Box* seqiterNext(Box* s) {
BoxedSeqIter* self = static_cast<BoxedSeqIter*>(s);
if (!self->next) {
Box* hasnext = seqiterHasnext(s);
Box* hasnext = NULL;
if (s->cls == seqiter_cls)
hasnext = seqiterHasnext(s);
else if (s->cls == seqreviter_cls)
hasnext = seqreviterHasnext(s);
else
RELEASE_ASSERT(0, "");
if (hasnext == False)
raiseExcHelper(StopIteration, "");
}
......
......@@ -12,3 +12,5 @@ for i in xrange(10):
for it in its:
print it.next(),
print
print list(itertools.dropwhile(lambda x: x == 0, reversed((1, 2, 3))))
......@@ -20,3 +20,10 @@ print list(reversed(RevIterTest()))
# xrange and list have __reversed__ methods
print list(xrange(0,9).__reversed__())
print list([1,2,3,4,5,6].__reversed__())
r = reversed((1, 2, 3))
try:
while True:
print r.next(),
except StopIteration:
print ""
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