def tbsource(tb, context=<NUM_LIT:6>):
lineno = tb.tb_lineno<EOL>frame = tb.tb_frame<EOL>if context > <NUM_LIT:0>:<EOL><INDENT>start = lineno - <NUM_LIT:1> - context//<NUM_LIT:2><EOL>log.debug("<STR_LIT>", lineno, start)<EOL>try:<EOL><INDENT>lines, dummy = inspect.findsource(frame)<EOL><DEDENT>except IOError:<EOL><INDENT>lines, index = ['<STR_LIT>'], <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>all_lines = lines<EOL>start = max(start, <NUM_LIT:1>)<EOL>start = max(<NUM_LIT:0>, min(start, len(lines) - context))<EOL>lines = lines[start:start+context]<EOL>index = lineno - <NUM_LIT:1> - start<EOL>if sys.version_info >= (<NUM_LIT:2>, <NUM_LIT:5>) and index > <NUM_LIT:0>:<EOL><INDENT>while lines[index-<NUM_LIT:1>].strip().endswith('<STR_LIT:\\>'):<EOL><INDENT>start -= <NUM_LIT:1><EOL>lines = all_lines[start:start+context]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>lines, index = ['<STR_LIT>'], <NUM_LIT:0><EOL><DEDENT>log.debug("<STR_LIT>", lines, index)<EOL>return (lines, index)<EOL>
Get source from  a traceback object.

    A tuple of two things is returned: a list of lines of context from
    the source code, and the index of the current line within that list.
    The optional second argument specifies the number of lines of context
    to return, which are centered around the current line.

    .. Note ::
       This is adapted from inspect.py in the python 2.4 standard library, 
       since a bug in the 2.3 version of inspect prevents it from correctly
       locating source lines in a traceback frame.