Skip to content

Instantly share code, notes, and snippets.

@4ft35t
Forked from notsobad/autopdb.py
Last active June 25, 2018 06:03
Show Gist options
  • Save 4ft35t/ab6ff12f61a040235343 to your computer and use it in GitHub Desktop.
Save 4ft35t/ab6ff12f61a040235343 to your computer and use it in GitHub Desktop.
#
# original: http://code.activestate.com/recipes/65287/
#
import sys
def info(type, value, tb):
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(type, value, tb)
else:
import traceback, pdb
# we are NOT in interactive mode, print the exception...
traceback.print_exception(type, value, tb)
print
# ...then start the debugger in post-mortem mode.
pdb.pm()
sys.excepthook = info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment