def extract_stack(f=None, limit=None):
 if (f is None):
  try:
   raise ZeroDivisionError
  except ZeroDivisionError:
   f = sys.exc_info()[2].tb_frame.f_back
 if (limit is None):
  if hasattr(sys, 'tracebacklimit'):
   limit = sys.tracebacklimit
 list = []
 n = 0
 while ((f is not None) and ((limit is None) or (n < limit))):
  lineno = f.f_lineno
  co = f.f_code
  filename = co.co_filename
  name = co.co_name
  linecache.checkcache(filename)
  line = linecache.getline(filename, lineno, f.f_globals)
  if line:
   line = line.strip()
  else:
   line = None
  list.append((filename, lineno, name, line))
  f = f.f_back
  n = (n + 1)
 list.reverse()
 return list

def extract_stack ( f = None , limit = None ) : if ( f is None ) : try : raise ZeroDivisionError except ZeroDivisionError : f = sys . exc_info ( ) [ 2 ] . tb_frame . f_back if ( limit is None ) : if hasattr ( sys , 'tracebacklimit' ) : limit = sys . tracebacklimit list = [ ] n = 0 while ( ( f is not None ) and ( ( limit is None ) or ( n < limit ) ) ) : lineno = f . f_lineno co = f . f_code filename = co . co_filename name = co . co_name linecache . checkcache ( filename ) line = linecache . getline ( filename , lineno , f . f_globals ) if line : line = line . strip ( ) else : line = None list . append ( ( filename , lineno , name , line ) ) f = f . f_back n = ( n + 1 ) list . reverse ( ) return list
extract the raw traceback from the current stack frame .