def _describe_frame(frame):
    """Print filename, line number and function name of a stack frame."""
    filename, name = frame.f_code.co_filename, frame.f_code.co_name
    lineno = frame.f_lineno
    with open(filename) as f:
        for no, line in enumerate(f):
            if no + 1 == lineno:
                break
    return """  File "%s", line %d, in %s
    %s
""" % (filename, lineno,
        name, line.strip())
