[Python-ideas] Make return inside a finally a SyntaxError

Bruce Leban bruce at leapyear.org
Sat Jul 18 04:25:03 CEST 2009


On Fri, Jul 17, 2009 at 7:13 PM, Guido van Rossum <guido at python.org> wrote:

> Since you agree that an exception raised in a finally block has
> well-defined semantics, why wouldn't a return statement?)
>

I think that to some extent exception > return. That is in both of these
cases

   try:
     return
   finally:
     raise Exception()

   try:
     raise Exception()
   finally:
     return

it makes sense to me that the caller would see an exception. I disagree that
it should be a syntax error. But it could be a runtime error when an
exception would get silently eaten.

--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090717/dd5c8b31/attachment.html>


More information about the Python-ideas mailing list