forked from codekansas/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdbrc
26 lines (21 loc) · 1.3 KB
/
pdbrc
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
# Enable tab completion
import rlcompleter
import pdb
pdb.Pdb.complete = rlcompleter.Completer(locals()).complete
# Sometimes when you do something funky, you may lose your terminal echo. This
# should restore it when spanwning new pdb.
import termios, sys
termios_fd = sys.stdin.fileno()
termios_echo = termios.tcgetattr(termios_fd)
termios_echo[3] = termios_echo[3] | termios.ECHO
termios_result = termios.tcsetattr(termios_fd, termios.TCSADRAIN, termios_echo)
# Interact in IPython
import IPython
alias interacti IPython.embed()
# Use `traceback` command to print full error logs.
# From here: https://stackoverflow.com/questions/6241200/how-can-i-see-the-details-of-an-exception-in-pythons-debugger
!global __currentframe, __stack; from inspect import currentframe as __currentframe, stack as __stack
!global __format_exception_only, __print_stack; from traceback import format_exception_only as __format_exception_only, print_stack as __print_stack
!global __Pdb; from pdb import Pdb as __Pdb
!global __pdb; __pdb = [__framerec[0].f_locals.get("pdb") or __framerec[0].f_locals.get("self") for __framerec in __stack() if (__framerec[0].f_locals.get("pdb") or __framerec[0].f_locals.get("self")).__class__ == __Pdb][-1]
alias traceback __print_stack(__pdb.stack[-1][0]); print "".join(__format_exception_only(*__exception__))