How to use the ipdb.post_mortem function in ipdb

To help you get started, we’ve selected a few ipdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leapcode / bitmask-dev / tests / functional / features / environment.py View on Github external
def _debug_on_error(context, step):
    if context.config.userdata.getbool("debug"):
        try:
            import ipdb
            ipdb.post_mortem(step.exc_traceback)
        except ImportError:
            import pdb
            pdb.post_mortem(step.exc_traceback)
github nicfit / eyeD3 / eyed3 / main.py View on Github external
eyed3.utils.console.printError(f"Uncaught exception: {ex}\n")
        eyed3.log.exception(ex)
        retval = 1

        if args.debug_pdb:
            try:
                with warnings.catch_warnings():
                    warnings.simplefilter("ignore", PendingDeprecationWarning)
                    # Must delay the import of ipdb as say as possible because
                    # of https://github.com/gotcha/ipdb/issues/48
                    import ipdb as pdb  # noqa
            except ImportError:
                import pdb  # noqa

            e, m, tb = sys.exc_info()
            pdb.post_mortem(tb)

    sys.exit(retval)
github facebookexperimental / eden / edenscm / mercurial / dispatch.py View on Github external
and not ui.pageractive
            and not ui.plain()
            and ui.formatted()
        ):
            ui.write_err(
                _(
                    "Starting ipdb for this exception\nIf you don't want the behavior, set devel.debugger to False\n"
                )
            )

            with demandimport.deactivated():
                import ipdb

            if not ui.tracebackflag:
                traceback.print_exc()
            ipdb.post_mortem(sys.exc_info()[2])
            os._exit(255)
        if not handlecommandexception(ui):
            raise

    return -1
github aldebaran / qibuild / python / qibuild / cmdparse.py View on Github external
"""This wraps the main method of an action so that:
       - backtrace is not printed by default
       - backtrace is printed is --backtrace was given
       - a pdb session is run if --pdb was given
    """
    try:
        module.do(args)
    except Exception as e:
        if args.pdb:
            traceback = sys.exc_info()[2]
            print ""
            print "### Exception:", e
            print "### Starting a debugger"
            try:
                import ipdb
                ipdb.post_mortem(traceback)
                sys.exit(0)
            except ImportError:
                import pdb
                pdb.post_mortem(traceback)
                sys.exit(0)
        if args.backtrace:
            raise
        logger = logging.getLogger("\n") # small hack
        logger.error(str(e))
        sys.exit(2)
github facebookexperimental / eden / eden / scm / edenscm / mercurial / dispatch.py View on Github external
debugtrace[debugger]()
            try:
                return _dispatch(req)
            finally:
                ui.flush()
        except:  # re-raises
            # Potentially enter the debugger when we hit an exception
            startdebugger = req.earlyoptions["debugger"]
            if startdebugger:
                # Enforce the use of ipdb, since it's always available and
                # we can afford the import overhead here.
                with demandimport.deactivated():
                    import ipdb

                traceback.print_exc()
                ipdb.post_mortem(sys.exc_info()[2])
                os._exit(255)
            raise
github facebookexperimental / eden / edenscm / mercurial / dispatch.py View on Github external
debugtrace[debugger]()
            try:
                return _dispatch(req)
            finally:
                ui.flush()
        except:  # re-raises
            # Potentially enter the debugger when we hit an exception
            startdebugger = req.earlyoptions["debugger"]
            if startdebugger:
                # Enforce the use of ipdb, since it's always available and
                # we can afford the import overhead here.
                with demandimport.deactivated():
                    import ipdb

                traceback.print_exc()
                ipdb.post_mortem(sys.exc_info()[2])
                os._exit(255)
            raise
github ponyorm / pony / pony / migrate / command.py View on Github external
def __exit__(self, e, m, tb):
        if not e:
            return
        try:
            import ipdb as pdb
        except ImportError:
            import pdb
        print(m.__repr__(), file=sys.stderr)
        pdb.post_mortem(tb)
github divio / divio-cli / aldryn_client / cli.py View on Github external
def exception_handler(type, value, traceback):
            click.secho(
                '\nAn exception occurred while executing the requested '
                'command:', fg='red'
            )
            hr(fg='red')
            sys.__excepthook__(type, value, traceback)
            click.secho('\nStarting interactive debugging session:', fg='red')
            hr(fg='red')
            pdb.post_mortem(traceback)
        sys.excepthook = exception_handler
github sisl / mechamodlearn / mechamodlearn / trainer.py View on Github external
def new_hook(typ, value, tb):
            old_hook(typ, value, tb)
            if typ != KeyboardInterrupt:
                import ipdb
                ipdb.post_mortem(tb)
github angr / angr / angr / path.py View on Github external
def debug(self):
        import ipdb
        ipdb.post_mortem(self.traceback)