#NEWLINE# def _fixed_getframes( etb , context = 1 , tb_offset = 0 ) : #NEWLINE# #INDENT# ( LNUM_POS , LINES_POS , INDEX_POS ) = ( 2 , 4 , 5 ) #NEWLINE# records = fix_frame_records_filenames ( inspect . getinnerframes ( etb , context ) ) #NEWLINE# rec_check = records [ tb_offset : ] #NEWLINE# try : #NEWLINE# #INDENT# rname = rec_check [ 0 ] [ 1 ] #NEWLINE# if ( ( rname == '<ipython console>' ) or rname . endswith ( '<string>' ) ) : #NEWLINE# #INDENT# return rec_check #NEWLINE# #UNINDENT# #UNINDENT# except IndexError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# aux = traceback . extract_tb ( etb ) #NEWLINE# assert ( len ( records ) == len ( aux ) ) #NEWLINE# for ( i , ( file , lnum , _ , _ ) ) in enumerate ( aux ) : #NEWLINE# #INDENT# maybeStart = ( ( lnum - 1 ) - ( context // 2 ) ) #NEWLINE# start = max ( maybeStart , 0 ) #NEWLINE# end = ( start + context ) #NEWLINE# lines = linecache . getlines ( file ) [ start : end ] #NEWLINE# if ( maybeStart < 0 ) : #NEWLINE# #INDENT# lines = ( ( [ '\n' ] * ( - maybeStart ) ) + lines ) #NEWLINE# #UNINDENT# if ( len ( lines ) < context ) : #NEWLINE# #INDENT# lines += ( [ '\n' ] * ( context - len ( lines ) ) ) #NEWLINE# #UNINDENT# buf = list ( records [ i ] ) #NEWLINE# buf [ LNUM_POS ] = lnum #NEWLINE# buf [ INDEX_POS ] = ( ( lnum - 1 ) - rname ) #NEWLINE# buf [ LINES_POS ] = lines #NEWLINE# records [ i ] = tuple ( buf ) #NEWLINE# #UNINDENT# return records [ tb_offset : ]