def fix_frame_records_filenames(records):
 fixed_records = []
 for (frame, filename, line_no, func_name, lines, index) in records:
  filename = py3compat.cast_unicode_py2(filename, 'utf-8')
  if (not filename.endswith(('.pyx', '.pxd', '.pxi'))):
   better_fn = frame.f_globals.get('__file__', None)
   if isinstance(better_fn, str):
    filename = better_fn
  fixed_records.append((frame, filename, line_no, func_name, lines, index))
 return fixed_records

def fix_frame_records_filenames ( records ) : fixed_records = [ ] for ( frame , filename , line_no , func_name , lines , index ) in records : filename = py3compat . cast_unicode_py2 ( filename , 'utf-8' ) if ( not filename . endswith ( ( '.pyx' , '.pxd' , '.pxi' ) ) ) : better_fn = frame . f_globals . get ( '__file__' , None ) if isinstance ( better_fn , str ) : filename = better_fn fixed_records . append ( ( frame , filename , line_no , func_name , lines , index ) ) return fixed_records
try to fix the filenames in each record from inspect .