lignite

pdb & stack dumping

Jul 14th, 2017
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.64 KB | None | 0 0
  1. import pdb
  2. import sys
  3. import traceback
  4.  
  5. class nob:
  6.     def __init__(self):
  7.         self.D = bytearray(b'', 'utf-8')
  8.  
  9.     def R(self, r):
  10.         self.D.extend(r)
  11.  
  12.     def L(self, l):
  13.         if(l <= len(self.D)):
  14.             return self.D[l-1]
  15.  
  16.     def A(self, a):
  17.         if(a < len(self.D)):
  18.             return(self.D[-a:])
  19.         elif(a == len(self.D)):
  20.             return(self.D)
  21.         else:
  22.             exit(0)
  23.  
  24. def excepthook(type, value, tb):
  25.     print "*** print_stack:"
  26.     traceback.print_stack()
  27.     pdb.set_trace()
  28.  
  29. try:
  30.     sys.excepthook = excepthook
  31.     print(dir(traceback))
  32.     Nob = nob()
  33.     Nob.R('D')
  34.     Nob.D.extend(Nob.D)
  35.     print(Nob.L(3))
  36.     print(Nob.A(1))
  37. except Exception as err:
  38.     exc_type, exc_value, exc_traceback = sys.exc_info()
  39.     print "*** print_tb:"
  40.     traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
  41.     print "*** print_exception:"
  42.     traceback.print_exception(exc_type, exc_value, exc_traceback,
  43.                               limit=2, file=sys.stdout)
  44.     print "*** print_exc:"
  45.     traceback.print_exc()
  46.     print "*** format_exc, first and last line:"
  47.     formatted_lines = traceback.format_exc().splitlines()
  48.     print formatted_lines[0]
  49.     print formatted_lines[-1]
  50.     print "*** format_exception:"
  51.     print repr(traceback.format_exception(exc_type, exc_value,
  52.                                           exc_traceback))
  53.     print "*** extract_tb:"
  54.     print repr(traceback.extract_tb(exc_traceback))
  55.     print "*** format_tb:"
  56.     print repr(traceback.format_tb(exc_traceback))
  57.     print "*** tb_lineno:", exc_traceback.tb_lineno
  58.     pdb.set_trace()
Add Comment
Please, Sign In to add comment