You are viewing an older version (9.10.0). Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.10.0 / IPython / core / debugger

module

IPython.core.debugger

source: /IPython/core/debugger.py :0

Members

Summary

No Docstrings

Additional content

Pdb debugger class.

This is an extension to PDB which adds a number of new features. Note that there is also the IPython.terminal.debugger class which provides UI improvements.

We also strongly recommend to use this via the ipdb package, which provides extra configuration options.

Among other things, this subclass of PDB:

  • supports many IPython magics like pdef/psource

  • hide frames in tracebacks based on __tracebackhide__

  • allows to skip frames based on __debuggerskip__

Global Configuration

The IPython debugger will by read the global ~/.pdbrc file. That is to say you can list all commands supported by ipdb in your ~/.pdbrc configuration file, to globally configure pdb.

Example

# ~/.pdbrc
skip_predicates debuggerskip false
skip_hidden false
context 25

Features

The IPython debugger can hide and skip frames when printing or moving through the stack. This can have a performance impact, so can be configures.

The skipping and hiding frames are configurable via the skip_predicates command.

By default, frames from readonly files will be hidden, frames containing __tracebackhide__ = True will be hidden.

Frames containing __debuggerskip__ will be stepped over, frames whose parent frames value of __debuggerskip__ is True will also be skipped.

>>> def helpers_helper():
...     pass
...
... def helper_1():
...     print("don't step in me")
...     helpers_helpers() # will be stepped over unless breakpoint set.
...
...
... def helper_2():
...     print("in me neither")
...

One can define a decorator that wraps a function between the two helpers:

>>> def pdb_skipped_decorator(function):
...
...
...     def wrapped_fn(*args, **kwargs):
...         __debuggerskip__ = True
...         helper_1()
...         __debuggerskip__ = False
...         result = function(*args, **kwargs)
...         __debuggerskip__ = True
...         helper_2()
...         # setting __debuggerskip__ to False again is not necessary
...         return result
...
...     return wrapped_fn

When decorating a function, ipdb will directly step into bar() by default:

>>> @foo_decorator
... def bar(x, y):
...     return x * y

You can toggle the behavior with

ipdb> skip_predicates debuggerskip false

or configure it in your .pdbrc

License

Modified from the standard pdb.Pdb class to avoid including readline, so that the command line completion of other programs which include this isn't damaged.

In the future, this class will be expanded with improvements over the standard pdb.

The original code in this file is mainly lifted out of cmd.py in Python 2.2, with minor changes. Licensing should therefore be under the standard Python terms. For details on the PSF (Python Software Foundation) standard license, see:

https://docs.python.org/2/license.html

All the changes since then are under the same license as IPython.

Aliases

  • IPython.core.debugger

Referenced by