We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

type-traceback

Traceback objects

Traceback objects represent a stack trace of an exception. A traceback object is created when an exception occurs. When the search for an exception handler unwinds the execution stack, at each unwound level a traceback object is inserted in front of the current traceback. When an exception handler is entered, the stack trace is made available to the program. (See try) It is accessible as sys.exc\_traceback, and also as the third item of the tuple returned by sys.exc\_info(). The latter is the preferred interface, since it works correctly when the program is using multiple threads. When the program contains no suitable handler, the stack trace is written (nicely formatted) to the standard error stream; if the interpreter is interactive, it is also made available to the user as sys.last\_traceback.

Special read-only attributes:

  • tb_next is the next level in the stack trace (towards the frame where the exception occurred), or None if there is no next level
  • tb_frame points to the execution frame of the current level
  • tb_lineno gives the line number where the exception occurred
  • tb_lasti indicates the precise instruction. The line number and last instruction in the traceback may differ from the line number of its frame object if the exception occurred in a try statement with no matching except clause or with a finally clause.