Neil Schemenauer wrote:

The translation of a block-statement could become:

        itr = EXPR1
        arg = None
        while True:
            try:
                VAR1 = next(itr, arg)
            except StopIteration:
                break
            try:
                arg = None
                BLOCK1
            except Exception, exc:
                err = getattr(itr, '__error__', None)
                if err is None:
                    raise exc
                err(exc)

That can't be right. When __error__ is called, if the iterator catches the exception and goes on to do another yield, the yielded value needs to be assigned to VAR1 and the block executed again. It looks like your version will ignore the value from the second yield and only execute the block again on the third yield.

So something like Guido's safe_loop() would miss every other
yield.

I think Guido was right in the first place, and __error__
really is just a minor variation on __next__ that shouldn't
have a separate entry point.

Greg



_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to