1 # This is startup file for interactive python debugger pdb.
2 # Use it like this in ~/.pdbrc:
4 # x = execfile("pdbrc.py")
5 # See http://wiki.python.org/moin/PdbRcIdea
13 # Command line history:
14 histfile = os.path.expanduser("~/.pdb_history")
17 readline.read_history_file(histfile)
22 def savehist(histfile=histfile):
26 histfilesize = os.environ.get('HISTFILESIZE') \
27 or os.environ.get('HISTSIZE')
30 histfilesize = int(histfilesize)
34 readline.set_history_length(histfilesize)
35 readline.write_history_file(histfile)
37 atexit.register(savehist)
40 def info(type, value, tb):
41 # return to debugger after fatal exception (Python cookbook 14.5):
46 if hasattr(sys, 'ps1') or not sys.stderr.isatty():
47 sys.__excepthook__(type, value, tb)
48 traceback.print_exception(type, value, tb)
56 # https://github.com/giampaolo/sysconf/blob/master/home/.pdbrc.py
59 #pdb.Pdb.complete = rlcompleter.Completer(locals()).complete
61 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498182
62 def complete(self, text, state, rlcompleter=rlcompleter):
63 """return the next possible completion for text, using the current frame's
66 This is called successively with state == 0, 1, 2, ... until it
67 returns None. The completion should begin with 'text'.
69 # keep a completer class, and make sure that it uses the current local scope
70 if not hasattr(self, 'completer'):
71 self.completer = rlcompleter.Completer(self.curframe.f_locals)
73 self.completer.namespace = self.curframe.f_locals
74 return self.completer.complete(text, state)
76 # Cleanup any variables that could otherwise clutter up the namespace.