def extract_tb(tb, limit = None):
if limit is None:<EOL><INDENT>if hasattr(sys, '<STR_LIT>'):<EOL><INDENT>limit = sys.tracebacklimit<EOL><DEDENT><DEDENT>list = []<EOL>n = <NUM_LIT:0><EOL>while tb is not None and (limit is None or n < limit):<EOL><INDENT>f = tb.tb_frame<EOL>lineno = tb.tb_lineno<EOL>co = f.f_code<EOL>filename = co.co_filename<EOL>name = co.co_name<EOL>linecache.checkcache(filename)<EOL>line = linecache.getline(filename, lineno, f.f_globals)<EOL>if line: line = line.strip()<EOL>else: line = None<EOL>list.append((filename, lineno, name, line))<EOL>tb = tb.tb_next<EOL>n = n+<NUM_LIT:1><EOL><DEDENT>return list<EOL>
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 quadruple (filename, line
    number, function name, text) representing the information that is
    usually 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.