[Python-ideas] Revised**12 PEP on Yield-From
jh at improva.dk
Thu Apr 23 02:20:20 CEST 2009
Jim Pryor wrote:
>>> I would call that a bug.
>> I agree with that.
> I don't understand why you're both counting this as a bug. It looks like
> exactly the behavior specified in PEP 342. When g.close() is evaluated,
> a GeneratorExit is thrown to the suspended 'yield' expression in foo.
> That exception is is not caught, so g terminates without executing the
> rest of its code. The 'raise ValueError' line is never executed.
You are of course completely right. What I *should* have tried was the
>>> def foo():
... yield 'bar'
... raise ValueError('baz')
>>> g = foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in foo
Which works as expected. No bug in sight. In that case I am not sure
what Eriks original problem was.
More information about the Python-ideas