Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuripiratello/e65366a57cec027d2947 to your computer and use it in GitHub Desktop.
Save yuripiratello/e65366a57cec027d2947 to your computer and use it in GitHub Desktop.
# coding: utf8
import bdb
import sys
# borrowed from: https://gist.github.com/rctay/3169104
def info(type, value, tb):
if (hasattr(sys, 'ps1')
or not sys.stdin.isatty()
or not sys.stdout.isatty()
or not sys.stderr.isatty()
or issubclass(type, bdb.BdbQuit)
or issubclass(type, SyntaxError)):
# 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()
#confs = config.read()
sys.excepthook = info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment