Re: ???: telling tracebacks to stop

tnb2d@henson.cs.virginia.edu
Wed, 23 Mar 94 14:13:18 EST

Steven D. Majewski writes:

| I *THINK* you want to skip the first 2, not the last two, is that
| correct ? ( or was it the other way around? )

I turns out you are correct, and if I had known this in the
first place I would have realized how simple the solution was! I'd
already written something that prints out tracebacks, so I didn't need
the function you posted. The source of my confusion came from the
fact that since I saw 'rolling back' through tracebacks as starting
where the error ocurred and going up the call-chain I thought I would
have to futz with the end of the printing process instead of the
beginning. In fact, the tracebacks start at the 'end' (what I thought
was the end) and end at the 'beginning' (where the exception was
raised), so all I had to do to fix it was just clip off the first two
tracebacks from sys.exc_traceback, using this:

def ClipTrace(trace):
for i in range(2):
trace = trace.tb_next
return trace

sys.exc_traceback = ClipTrace(sys.exc_traceback)

It was that simple! Thanks for the tip,

-------> Tommy.

"Subvert the parental paradigm - Refuse Birth."