Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 26 |
Nodes: | 6 (1 / 5) |
Uptime: | 18:48:26 |
Calls: | 629 |
Files: | 1,186 |
D/L today: |
19 files (29,897K bytes) |
Messages: | 167,605 |
Recently I have been increasingly adding this piece of code as
a preamble to a lot of my code.
import (sys, os, ipdb)
def debug_hook(exc_type, exc_value, traceback):
if exc_type is KeyboardInterrupt:
sys.__excepthook__(exc_type, exc_value, traceback)
return
print(f"Uncaught exception: {exc_type.__name__}: {exc_value}")
ipdb.post_mortem(traceback)
if os.environ.get('DEBUG'): sys.excepthook = debug_hook
debug_hook.py(19)cause_exception()(Pdb) i
return 1 / 0 # Will raise ZeroDivisionError
Hi,
Recently I have been increasingly adding this piece of code as
a preamble to a lot of my code.
import (sys, os, ipdb)
def debug_hook(exc_type, exc_value, traceback):
if exc_type is KeyboardInterrupt:
sys.__excepthook__(exc_type, exc_value, traceback)
return
print(f"Uncaught exception: {exc_type.__name__}: {exc_value}")
ipdb.post_mortem(traceback)
if os.environ.get('DEBUG'): sys.excepthook = debug_hook
Recently I have been increasingly adding this piece of code as-a Thanks!
a preamble to a lot of my code.
-a-a import (sys, os, ipdb)
-a-a def debug_hook(exc_type, exc_value, traceback):
-a-a-a-a-a-a if exc_type is KeyboardInterrupt:
-a-a-a-a-a-a-a-a-a-a sys.__excepthook__(exc_type, exc_value, traceback) -a-a-a-a-a-a-a-a-a-a return
-a-a-a-a-a-a print(f"Uncaught exception: {exc_type.__name__}: {exc_value}") -a-a-a-a-a-a ipdb.post_mortem(traceback)
-a-a if os.environ.get('DEBUG'): sys.excepthook = debug_hook
debug_hook.py(19)cause_exception()(Pdb) i
return 1 / 0-a # Will raise ZeroDivisionError