
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? Alex

Hello Alex, On Mon, Dec 22, 2003 at 01:32:55AM +0100, Alex Martelli wrote:
The whole business of StopIteration vs. the interp-level "NoValue" exception is unclean, but your hack to change the semantics of the "raise" statement is worse :-) Instead, you should catch the OperationError in pypy_next(), in the call to Frame.run(), and turn it into a NoValue. A bientot, Armin.

Hello Alex, On Mon, Dec 22, 2003 at 01:32:55AM +0100, Alex Martelli wrote:
The whole business of StopIteration vs. the interp-level "NoValue" exception is unclean, but your hack to change the semantics of the "raise" statement is worse :-) Instead, you should catch the OperationError in pypy_next(), in the call to Frame.run(), and turn it into a NoValue. A bientot, Armin.
participants (2)
-
Alex Martelli
-
Armin Rigo