[Python-ideas] Revised**12 PEP on Yield-From

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Apr 23 03:20:22 CEST 2009


Erik Groeneveld wrote:

> When no exception has been raised, it will raise the
> RuntimeError('generator ignored GeneratorExit').  And when an
> exception has been raised (regardless what type), it will exit just
> normally.

Eh? That's not what happens according to the following
experiment:

   def g():
     try:
       yield
     except GeneratorExit:
       raise ValueError("Blarg!")

   gi = g()
   gi.next()
   gi.close()

which produces

Traceback (most recent call last):
   File "g.py", line 9, in <module>
     gi.close()
   File "g.py", line 5, in g
     raise ValueError("Blarg!")
ValueError: Blarg!

-- 
Greg



More information about the Python-ideas mailing list