patch_ipdb#
Patches the ipdb debugger to enable rich output (e.g. with treescope).
displayhook
is the method that is called to print outputs in PDB to the
console. This isn’t a documented attribute on pdb.PDB
but overriding it
appears to work correctly.
This patch is fairly unergonomic, since it directly rewrites methods on the
IPython Pdb
class. However, modifying this displayhook is otherwise fairly
complex, since the debugger class is hardcoded in various places to enable
IPython magics like %debug
. This also has the advantage of automatically
patching all subclasses of IPython’s debugger as well (unless they specifically
override the displayhook).
Note that this will only use treescope
if treescope has been registered
as the default IPython display hook, using treescope.register_as_default()
Functions
|
Custom displayhook to display results with IPython. |
|
Patches the IPython debugger to use |
Unpatches the IPython debugger so that it uses its original displayhook. |