traceback
This module provides a standard interface to format and print stack traces of Python programs. It exactly mimics the behavior of the Python interpreter when it prints a stack trace. This is useful when you want to print stack traces under program control, e.g. in a ``wrapper'' around the interpreter.
The module uses traceback objects -- this is the object type
that is stored in the variables sys.exc_traceback
and
sys.last_traceback
.
The module defines the following functions:
None
, all entries are printed.
None
,
all entries are extracted. A ``pre-processed'' stack trace entry is a
quadruple (filename, line number, function name,
line text) representing the information that is usually printed
for a stack trace. The line text is a string with leading and
trailing whitespace stripped; if the source is not available it is
None
.
print_tb
in the
following ways: (1) if traceback is not None
, it prints a
header ``Traceback (innermost last):
''; (2) it prints the
exception type and value after the stack trace; (3) if
type is SyntaxError
and value has the appropriate
format, it prints the line where the syntax error occurred with a
caret indication the approximate position of the error.
print_exception(sys.exc_type,
sys.exc_value,
sys.exc_traceback,
limit)
.
print_exception(sys.last_type,
sys.last_value,
sys.last_traceback,
limit)
.