summaryrefslogtreecommitdiff
path: root/pypers/pep318/working/debugger.py
blob: 30510dfb40950c5c7c95dfbefa15a09795fcdc13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import sys

def info(type, value, tb):
    if hasattr(sys, 'ps1') or not sys.stderr.isatty() or \
           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()

sys.excepthook = info