def print_tb(tb, limit=None, file=None):
 if (file is None):
  file = sys.stderr
 if (limit is None):
  if hasattr(sys, 'tracebacklimit'):
   limit = sys.tracebacklimit
 n = 0
 while ((tb is not None) and ((limit is None) or (n < limit))):
  f = tb.tb_frame
  lineno = tb.tb_lineno
  co = f.f_code
  filename = co.co_filename
  name = co.co_name
  _print(file, ('  File "%s", line %d, in %s' % (filename, lineno, name)))
  linecache.checkcache(filename)
  line = linecache.getline(filename, lineno, f.f_globals)
  if line:
   _print(file, ('    ' + line.strip()))
  tb = tb.tb_next
  n = (n + 1)

def print_tb ( tb , limit = None , file = None ) : if ( file is None ) : file = sys . stderr if ( limit is None ) : if hasattr ( sys , 'tracebacklimit' ) : limit = sys . tracebacklimit n = 0 while ( ( tb is not None ) and ( ( limit is None ) or ( n < limit ) ) ) : f = tb . tb_frame lineno = tb . tb_lineno co = f . f_code filename = co . co_filename name = co . co_name _print ( file , ( '  File "%s", line %d, in %s' % ( filename , lineno , name ) ) ) linecache . checkcache ( filename ) line = linecache . getline ( filename , lineno , f . f_globals ) if line : _print ( file , ( '    ' + line . strip ( ) ) ) tb = tb . tb_next n = ( n + 1 )
print up to limit stack trace entries from the traceback tb .