[Python-Dev] Re-raise in absence of an "active" exception

Guido van Rossum guido at python.org
Thu Jun 24 00:53:57 EDT 2004

> http://python.org/sf/973103 points to two interesting bugs in Python:
> First, using a re-raise after the except-block has completed will
> still re-raise the last exception. Even though the language spec
> is ambiguous (what is the "last expression that was active in the
> current scope" (*)), I doubt this is intended.

Actually, it *is* intended.  The exception state remains valid until
another exception is raised in the same or an outer scope.

> It then also shows that the error you "normally" get for a reraise
> in absence of an exception is
> TypeError: exceptions must be classes, instances, or strings 
> (deprecated), not NoneType
> I think this is in violation of the language description, which says
> "If no exception is active in the current scope, an exception is raised 
> indicating this error."
> "This" error probably being "no active exception", not "exception must
> not be NoneType".
> What do you think?

Here I agree -- the error message is a little dumb.

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

More information about the Python-Dev mailing list