[Python-ideas] Yield-From: Revamped expansion

Bruce Frederiksen dangyogi at gmail.com
Mon Mar 23 02:23:19 CET 2009

Nick Coghlan wrote:
> I'd adjust the inner exception handlers to exploit the fact that
> SystemExit and GeneratorExit don't inherit from BaseException:
> [...]
>             except:
>                 # Covers SystemExit, GeneratorExit and
>                 # anything else that doesn't inherit
>                 # from Exception
>                 _m = getattr(_i, 'close', None)
>                 if _m is not None:
>                     _m()
>                 raise
This feels better to me too.  Though it seems that _i.throw would be 
more appropriate than _i.close (except call _i.close is there is no 
_i.throw -- is it possible to have a close and not a throw?).

I like the idea that "finally" (in try/finally) means finally and not 
"maybe finally" (which boils down to finally in CPython due to the 
reference counting collector, but maybe finally in Jython, IronPython or 

-bruce frederiksen

More information about the Python-ideas mailing list