Human → Computer

Better debugging with pdbpp

written by Patrick Gerken on 2011-01-11

A short while ago I found out about an alternative to ipdb, pdbpp. among other features pdbpp offers, tab completion, syntax highlighting better code display (sticky mode). It extends pdb so import pdb;pdb.set_trace() still works.

Sadly, there is a single thing one has to do to make it work with zope. When pdb fires up, it loads some third party tools, one of them being pyrepl. Pyrepl tries to register some signal handlers and this is usually impossible in your code because you are just in a simple thread where this is forbidden. You will get the wrong error message:

AttributeError: UnixConsole instance has not attribute 'old_sigwinch'

To get around this issue, create a file in your home directory named and add the following content:

from fancycompleter import DefaultConfig

class Config(DefaultConfig):
    prefer_pyrepl = False

Pdbpp uses the fancycompleter for tab completion and we change the preferences here, so that pyrepl won't be used any longer.