Debugger

Module: Debugger

Inheritance diagram for IPython.Debugger:

Pdb debugger class.

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 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:

http://www.python.org/2.2.3/license.html

Classes

Pdb

class IPython.Debugger.Pdb(color_scheme='NoColor', completekey=None, stdin=None, stdout=None)

Bases: pdb.Pdb

Modified Pdb class, does not load readline.

__init__()
checkline()

Check whether specified line seems to be executable.

Return lineno if it is, 0 if not (e.g. a docstring, comment, blank line or EOF). Warning: testing is not comprehensive.

do_d()
do_down()
do_l()
do_list()
do_pdef()

The debugger interface to magic_pdef

do_pdoc()

The debugger interface to magic_pdoc

do_pinfo()

The debugger equivalant of ?obj

do_q()
do_quit()
do_u()
do_up()
format_stack_entry()
interaction()
list_command_pydb()

List command to use if we have a newer pydb installed

new_do_down()
new_do_frame()
new_do_quit()
new_do_restart()

Restart command. In the context of ipython this is exactly the same thing as ‘quit’.

new_do_up()
postloop()
print_list_lines()

The printing (as opposed to the parsing part of a ‘list’ command.

print_stack_entry()
print_stack_trace()
set_colors()

Shorthand access to the color table scheme selector method.

Tracer

class IPython.Debugger.Tracer(colors=None)

Bases: object

Class for local debugging, similar to pdb.set_trace.

Instances of this class, when called, behave like pdb.set_trace, but providing IPython’s enhanced capabilities.

This is implemented as a class which must be initialized in your own code and not as a standalone function because we need to detect at runtime whether IPython is already active or not. That detection is done in the constructor, ensuring that this code plays nicely with a running IPython, while functioning acceptably (though with limitations) if outside of it.

__init__()

Create a local debugger instance.

Parameters :
  • colors (None): a string containing the name of the color scheme to

use, it must be one of IPython’s valid color schemes. If not given, the function will default to the current IPython scheme when running inside IPython, and to ‘NoColor’ otherwise.

Usage example:

from IPython.Debugger import Tracer; debug_here = Tracer()

... later in your code debug_here() # -> will open up the debugger at that point.

Once the debugger activates, you can use all of its regular commands to step through code, set breakpoints, etc. See the pdb documentation from the Python standard library for usage details.

Functions

IPython.Debugger.BdbQuit_IPython_excepthook()
IPython.Debugger.BdbQuit_excepthook()
IPython.Debugger.decorate_fn_with_doc()

Make new_fn have old_fn’s doc string. This is particularly useful for the do_... commands that hook into the help system. Adapted from from a comp.lang.python posting by Duncan Booth.

Table Of Contents

Previous topic

DPyGetOpt

Next topic

Itpl

This Page