Package: ipdbx
ipdbxis an improved version ofipdbthat provides extra functionality and customisation.Python 2 support has been dropped to make way for new features.Useipdbxexports functions to access theIPythondebugger, which features
tab completion, syntax highlighting, better tracebacks, better introspection
with the same interface as thepdbmodule.Example usage:importipdbxipdbx.set_trace()ipdbx.set_trace(context=5)# will show five lines of code# instead of the default three lines# or you can set it via IPDB_CONTEXT_SIZE env variable# or setup.cfg fileipdbx.set_trace(pretrace='/useful/debug/tools.py')# can be set via IPDB_PRETRACE# env variable. pretrace also# accepts the same type of args# as ipdbx.run(), ipdbx.runcall()# and ipdbx.runeval()ipdbx.pm()ipdbx.run('x[0] = 3')result=ipdbx.runcall(function,arg0,arg1,kwarg='foo')result=ipdbx.runeval('f(1,2) - 3')Patchingsys.breakpointhookto callipdbxwhen callingbreakpoint():importipdbximportsyssys.breakpointhook=ipdbx.set_trace# You can also call set_trace with default arguments, likewise:fromfunctoolsimportpartialsys.breakpointhook=partial(ipdbx.set_trace,context=30,pretrace='/my/favourite/things.py')Arguments foripdbx.set_traceTheipdbx.set_tracefunction accepts the following optional parameters:frame, aframeobject (defaults to last);context: int, which will show as many lines of code as defined;cond: bool, which accepts boolean values (such asabc == 17) and will start ipdb’s interface whenevercondequals toTrue;pretrace, which accepts a file path, a python statement string, or a code object, which it will execute immediately before starting the debugger.Using configuration fileIt’s possible to set up context using a.ipdbfile on your home folder orsetup.cfgon your project folder. You can also set your file location via env var$IPDB_CONFIG.
Your environment variable has priority over the home configuration file,
which in turn has priority over the setup config file. Currently, only context setting
is available.A valid setup.cfg is as follows[ipdb]
context=5
pretrace=./file.pyA valid .ipdb is as followscontext=5
pretrace="import inspect"The post-mortem function,ipdbx.pm(), is equivalent to the magic function%debug.If you installipdbxwith a tool which supportssetuptoolsentry points,
anipdbxscript is made for you. You can use it to debug your python scripts like$ bin/ipdbx mymodule.pyYou can also enclose code with thewithstatement to launch ipdb if an exception is raised:fromipdbximportlaunch_ipdb_on_exceptionwithlaunch_ipdb_on_exception():...Issues withstdoutSome tools, likenosefiddle withstdout.If you use a tool that fiddles withstdout, you should
explicitly ask forstdoutfiddling by usingipdbxlike thisimportipdbxipdbx.sset_trace()ipdbx.spm()fromipdbximportslaunch_ipdb_on_exceptionwithslaunch_ipdb_on_exception():...Developmentipdbxsource code and tracker are athttps://github.com/giladbarnea/ipdbx.Pull requests should take care of updating the changelogHISTORY.txt.Manual testingTo test your changes, make use ofmanual_test.py. Create a virtual environment,
install IPython and runpython manual_test.pyand check if your changes are in effect.
If possible, create automated tests for better behaviour control.