[Python-Dev] Exception masking/chaining
Guido van Rossum
guido@python.org
Wed, 11 Jun 2003 10:35:32 -0400
> This could be done automatically, i.e. whenever you call
> PyErr_SetString() etc. the currently active exception will be normalized
> and put into a fourth global variable (exc_cause). In Python code
> whenever a exception handler raises a new exception the exception
> that is currently handled could be set as the cause for this
> exception automatically by the raise statement.
More globals of course defeat the purpose (one of the reasons for
putting the traceback in the exception is to get rid of
sys.exc_traceback).
I also think that doing this automatically whenever PyErr_Set*() is
called would cause a lot of spurious tracebacks. (Unless the idea is
to skip the chaining if the original exception has an empty traceback;
that will almost always be the case for exceptions raised at the C
level.) I worry about backwards compatibility.
--Guido van Rossum (home page: http://www.python.org/~guido/)