[Python-Dev] with_traceback

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 1 09:27:26 CET 2007

James Y Knight wrote:

> It seems to me that a stack trace should always be attached to an  
> exception object at creation time

Um. Yes. Well, that's certainly an innovative solution...

> The traceback won't necessarily be *useful*,

Almost completely use*less*, I would have thought.
The traceback is mostly used to find out where
something went wrong, not where it went right (i.e.
successful creation of the exception).

> creating the traceback is generally very expensive,

I don't think so -- isn't it just a linked list
of existing stack frames? That should be very cheap
to create.

>  From http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Throwable.html:
>>A throwable contains a snapshot of the execution stack of its  
>>thread at the time it was created.

This would be a major and surprising change to Python

It would also be considerably *more* expensive to implement
than the current scheme, because it would require copying the
entire stack, instead of just linking stack frames together
as they are unwound during the search for an exception


More information about the Python-Dev mailing list