l.s.stacktrace : module documentation

Part of lp.services

Replacement for some standard library traceback module functions.

These honor traceback supplements as defined in zope.exceptions.

Function print_list Print the list of tuples as returned by extract_tb() or
Function format_list Format a list of traceback entry tuples for printing.
Function print_stack Print a stack trace from its invocation point.
Function extract_stack Extract the raw traceback from the current stack frame.
Function extract_tb Return list of up to limit pre-processed entries from traceback.
Function _try_except Undocumented
Function _get_frame if the frame is None, make one.
Function _fmt Return the string as deemed suitable for the extra information.
Function _get_limit Return the limit or the globally-set limit, if any.
Function _get_frame_data Given a frame and a lineno, return data for each item of extract_*.
def _try_except(callable, *args, **kwargs):
Undocumented
def _get_frame(f):
if the frame is None, make one.
def _fmt(string):
Return the string as deemed suitable for the extra information.
def print_list(extracted_list, file=None):
Print the list of tuples as returned by extract_tb() or extract_stack() as a formatted stack trace to the given file.
def format_list(extracted_list):
Format a list of traceback entry tuples for printing.

Given a list of tuples as returned by extract_tb() or extract_stack(), return a list of strings ready for printing. Each string in the resulting list corresponds to the item with the same index in the argument list. Each string ends in a newline; the strings may contain internal newlines as well, for those items whose source text line or supplement or info are not None.

def print_stack(f=None, limit=None, file=None):
Print a stack trace from its invocation point.

The optional 'f' argument can be used to specify an alternate stack frame at which to start. The optional 'limit' and 'file' arguments have the same meaning as for print_exception().

def _get_limit(limit):
Return the limit or the globally-set limit, if any.
def _get_frame_data(f, lineno):
Given a frame and a lineno, return data for each item of extract_*.
def extract_stack(f=None, limit=None):
Extract the raw traceback from the current stack frame.

The return value has the same format as for extract_tb(). The optional 'f' and 'limit' arguments have the same meaning as for print_stack(). Each item in the list is a septuple (filename, line number, function name, text, module name, optional supplement dict, optional info string), and the entries are in order from oldest to newest stack frame.

def extract_tb(tb, limit=None):
Return list of up to limit pre-processed entries from traceback.

This is useful for alternate formatting of stack traces. If 'limit' is omitted or None, all entries are extracted. A pre-processed stack trace entry is a sextuple (filename, line number, function name, text, module name, optional supplement dict, optional info string) representing the information that is printed for a stack trace. The text is a string with leading and trailing whitespace stripped; if the source is not available it is None. The supplement dict has keys 'source_url', 'line', 'column', 'expression', 'warnings' (an iterable), and 'extra', any of which may be None.

API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.