[Python-Dev] patch: try/finally in generators
Guido van Rossum
guido@python.org
Mon, 29 Jul 2002 13:34:01 -0400
> http://www.python.org/sf/584626
>
> This patch removes the limitation of not allowing yield in the try part
> of a try/finally. The dealloc function of a generator checks if the
> generator is still alive and resumes it one last time from the return
> instruction at the end of the code, causing any try/finally blocks to be
> triggered. Any exceptions raised are treated just like exceptions in a
> __del__ finalizer (printed and ignored).
I'm not sure I understand what it does. The return instruction at the
end of the code, if I take this literally, isn't enclosed in any
try/finally blocks. So how can this have the desired effect?
Have you verified that Jython can implement these semantics too?
Do you *really* need this?
--Guido van Rossum (home page: http://www.python.org/~guido/)