(frame, context=1)
return Traceback(filename, lineno, frame.f_code.co_name, lines, index)
Get information about a frame or traceback object.

    A tuple of five things is returned: the filename, the line number of
    the current line, the function name, 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.
Get information about a frame or traceback object.
Get information about a frame or traceback object .
def getframeinfo(frame, context=1):
    """Get information about a frame or traceback object.

    A tuple of five things is returned: the filename, the line number of
    the current line, the function name, 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."""
    if istraceback(frame):
        lineno = frame.tb_lineno
        frame = frame.tb_frame
    else:
        lineno = frame.f_lineno
    if not isframe(frame):
        raise TypeError('{!r} is not a frame or traceback object'.format(frame))

    filename = getsourcefile(frame) or getfile(frame)
    if context > 0:
        start = lineno - 1 - context//2
        try:
            lines, lnum = findsource(frame)
        except OSError:
            lines = index = None
        else:
            start = max(0, min(start, len(lines) - context))
            lines = lines[start:start+context]
            index = lineno - 1 - start
    else:
        lines = index = None

    return Traceback(filename, lineno, frame.f_code.co_name, lines, index)
def getframeinfo ( frame , context = 1 ) : if istraceback ( frame ) : lineno = frame . tb_lineno frame = frame . tb_frame else : lineno = frame . f_lineno if not isframe ( frame ) : raise TypeError ( '{!r} is not a frame or traceback object' . format ( frame ) ) filename = getsourcefile ( frame ) or getfile ( frame ) if context > 0 : start = lineno - 1 - context // 2 try : lines , lnum = findsource ( frame ) except OSError : lines = index = None else : start = max ( 0 , min ( start , len ( lines ) - context ) ) lines = lines [ start : start + context ] index = lineno - 1 - start else : lines = index = None return Traceback ( filename , lineno , frame . f_code . co_name , lines , index )