[Python-3000] self-contained exceptions

Guido van Rossum guido at python.org
Thu Jan 4 06:11:10 CET 2007


On 1/3/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> Or perhaps translate blocks of the form:
>
>      except ExcType, e:
>          # body
>
> to:
>
>      except ExcType, e:
>          try:
>              # body
>          finally:
>              del e
>
> This won't stop you from creating a cycle explicitly, of course, but it
> would ensure that the simple cases would be cycle-free.

+1!

I used to dislike this because there are use cases for letting the
exception survive the except clause, but I think I can get used to it,
and it seems the most straightforward solution of all that I've seen.
We could completely get rid of sys.exc_info()! I think we have a
winner here.

Explicitly created cycles are no big deal IMO -- these are no worse
than current code that explicitly stores sys.exc_info()[2].

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list