diff --git a/main.py b/main.py old mode 100644 new mode 100755 index d83e8d21..be6a7ee4 --- a/main.py +++ b/main.py @@ -20,6 +20,7 @@ """ from pandastable.app import DataExplore, TestApp +from pandastable import debug def main(): """Run the application from outside the module - used for diff --git a/pandastable/debug.py b/pandastable/debug.py new file mode 100644 index 00000000..d25281e2 --- /dev/null +++ b/pandastable/debug.py @@ -0,0 +1,21 @@ +# When loaded, this python module will automagically start up the +# debugger in response to exceptions. Many thanks to tzot on +# StackExchange: https://stackoverflow.com/a/242531/289934 + +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() # deprecated + pdb.post_mortem(tb) # more "modern" + +sys.excepthook = info