On 3/13/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > 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.
We can still gain some simplification there, as we shouldn't have to keep shadow copies of these triples in each frame and in each thread state. > 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. I *think* that's how it works now, and I don't intend to break this. > > 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? Yes. After learning that there isn't much of a performance gain and there aren't many users, and after looking into other solutions, I really think that having the tb attached to the exc is the best approach. > What about thread safety? Do we just document that using > pre-instantiated exceptions is not thread-safe? It's more than non-thread-safe. It's unsafe, period. And yes, we document this. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com