Python traceback Functions

EditRocket provides the following information on traceback functions in the Python source code builder.

extract_stack([f[, limit]]) - Extract the raw traceback from the current stack frame.

extract_tb(traceback[, limit]) - Return a list of up to limit ``pre-processed'' stack trace entries extracted from the traceback object traceback.

format_exc([limit]) - This is like print_exc(limit) but returns a string instead of printing to a file.

format_exception(type, value, tb[, limit]) - Format a stack trace and the exception information.

format_exception_only(type, value) - Format the exception part of a traceback.

format_list(list) - Given a list of tuples as returned by extract_tb() or extract_stack(), return a list of strings ready for printing.

format_stack([f[, limit]]) - A shorthand for format_list(extract_stack(f, limit)).

format_tb(tb[, limit]) - A shorthand for format_list(extract_tb(tb, limit)).

print_exc([limit[, file]]) - This is a shorthand for print_exception(sys.

print_exception(type, value, traceback[, limit[, file]]) - Print exception information and up to limit stack trace entries from traceback to file.

print_last([limit[, file]]) - This is a shorthand for print_exception(sys.

print_stack([f[, limit[, file]]]) - This function prints a stack trace from its invocation point.

print_tb(traceback[, limit[, file]]) - Print up to limit stack trace entries from traceback.

tb_lineno(tb) - This function returns the current line number set in the traceback object.