naive question about tracebacks

Tim Peters tim_one at email.msn.com
Thu Feb 20 06:46:33 EST 2003


[Andrew Koenig]
> The hidden point is that every other system I've seen that provides
> what it calls a traceback does so by printing the most recent call
> context first.

Well, when a C program blows up, the debugger prints the stack frames as it
unwinds the stack.  Python isn't like that:  it can't know whether "blows
up" actually explodes until after it unwinds the whole stack, looking for an
except: clause.  By the time Python knows explosion is appropiate, the stack
has already been fully unwound, and it's got a singly-linked list of
traceback objects pointing in the other direction then, built up during the
unwinding.  Both kinds of implementations do what's most natural for them
(notwithstanding that either *could* do what the other does instead, at the
cost of more fiddling).






More information about the Python-list mailing list