???: telling tracebacks to stop

tnb2d@henson.cs.virginia.edu
Wed, 23 Mar 94 08:43:31 EST

I have an application that spawns off other processes and
executes the input (python code) it receives from them. When an
error/exception occurs in this input I want the tracebacks to be
printed, but I want the printing to stop before it gets to the two
topmost frames. The last two frames printed are ALWAYS THE SAME
becuase they are the ineer loops in which I'm reading and executing
this input. This is an implementation detail that I would rather my
users not have to deal with when trying to debug their code.
I know that by setting sys.tracebacklimit I can keep the
number of tracebacks printed to a constant limit, but what I want is
to just make sure a traceback print rolls through all but the LAST TWO
levels? This means that the number of tracebacks printed will vary
depending on where an error occurs, but it will always print two less
tracebacks than are present. There is also a guarantee that there
will always be AT LEAST TWO tracebacks regardless of the error,
because ALL python code in this application is executed in the same
place by the same mechanism.
The easiest thing from my point of view would be to have a
traceback object maintain some indication of how deep it is, so I
could just decrement it by two before sending it to be printed. But
I'm not that up on the implementation of traceback objects so I'm not
sure if this is feasible.
Help?

-------> Tommy.

"Subvert the parental paradigm - Refuse Birth."