[Python-3000] exception info [was: Discussions with no PEPs]

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Mar 13 10:39:03 CET 2007


Guido van Rossum wrote:

> The internal mechanism for bubbling an exception up the stack until an
> except clause catches it could continue to use the (class, instance,
> traceback) triple,

Hmmm, so most of that complexity will still be there at
the C level. I was hoping there might be some simplification
there as well. However...

> and if raise is passed a class instead of an
> instance, the instance would be NULL; when forced to instantiate the
> exception, the traceback collected up to that point is attached to it.

Would this apply to Python code as well? I.e. if you use
a raise statement with a class, it doesn't get instantiated
immediately? And if you catch it with an except clause which
doesn't capture the exception, it's never instantiated?
That would be a bonus.

> If an instance was passed to raise, the __traceback__ pointer in the
> instance is updated each time we leave a stack frame.

So it seems we're back to declaring pre-instantiated
exceptions to be bad style, which you said you didn't
like earlier -- have you changed your mind?

What about thread safety? Do we just document that using
pre-instantiated exceptions is not thread-safe?

--
Greg


More information about the Python-3000 mailing list