Ejemplo n.º 1
0
    def post_mortem(self):
        try:
            traceback.print_exc()
            tb = sys.exc_info()[2]

            if self.force_ipdb or is_ipython():
                # https://github.com/gotcha/ipdb/blob/master/ipdb/__main__.py
                from IPython.terminal.interactiveshell import (
                    TerminalInteractiveShell)
                p = TerminalInteractiveShell().debugger_cls()
                p.botframe = sys._getframe().f_back  # I do not know why this
                # is nessesary, but without this hack it does not work
                p.interaction(None, tb)
            else:
                pdb.post_mortem(tb)
        except Exception as e:
            print('#' * 40)
            print('debug_on does not alwais work with sacred. '
                  'Use -D for sacred applications')
            print('#' * 40)
            raise e