-
Notifications
You must be signed in to change notification settings - Fork 43
/
.pdbrc.py
41 lines (34 loc) · 1.23 KB
/
.pdbrc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498182
def complete(self, text, state):
"""return the next possible completion for text, using the current frame's
local namespace
This is called successively with state == 0, 1, 2, ... until it
returns None. The completion should begin with 'text'.
"""
# keep a completer class, and make sure that it uses the current local scope
if not hasattr(self, 'completer'):
self.completer = rlcompleter.Completer(self.curframe.f_locals)
else:
self.completer.namespace = self.curframe.f_locals
return self.completer.complete(text, state)
# Command line history:
import readline
histfile = os.path.expanduser("~/.pdb-pyhist")
try:
readline.read_history_file(histfile)
except IOError:
pass
import atexit
atexit.register(readline.write_history_file, histfile)
del histfile
readline.set_history_length(1000)
# return to debugger after fatal exception (Python cookbook 14.5):
def info(type, value, tb):
import sys
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
sys.__excepthook__(type, value, tb)
import traceback, pdb
traceback.print_exception(type, value, tb)
print
pdb.pm()
sys.excepthook = info