[pypy-dev] help fully fixing generators...?

Alex Martelli aleaxit at yahoo.com
Mon Dec 22 01:32:55 CET 2003

enumerate currently does not work -- and it does not work because generators
(which enumerate, implemented at app level, uses) don't behave correctly
when a StopIteration is raised -- they propagate it (propagate the 
OperationError, at interpreter level) rather than turning it into a "clean 
return from the generator" (a SGeneratorReturn, at interpreter level).  I
easily fixed it for a simple "raise StopIteration" in the generator itself, 
and committed that change (as well as the unit-test showing the bug 
existed),  but I'm not sure where to edit to fix it when the StopIteration 
is being PROPAGATED from a call to something.next() in the generator, which 
is what enumerate needs.

I haven't checked in a unit test showing the problem, but, basically, the
issue is something like:

def agen():
    it = iter('ciao')
    while 1: yield it.next()

print list(agen())

in CPython this works fine, but in pypy it currently doesn't (yet).

Suggestions, anybody?


More information about the Pypy-dev mailing list