Show More
@@ -27,6 +27,7 b' http://www.python.org/2.2.3/license.html"""' | |||
|
27 | 27 | from __future__ import print_function |
|
28 | 28 | |
|
29 | 29 | import bdb |
|
30 | import functools | |
|
30 | 31 | import linecache |
|
31 | 32 | import sys |
|
32 | 33 | |
@@ -59,10 +60,18 b' else:' | |||
|
59 | 60 | # Allow the set_trace code to operate outside of an ipython instance, even if |
|
60 | 61 | # it does so with some limitations. The rest of this support is implemented in |
|
61 | 62 | # the Tracer constructor. |
|
62 | def BdbQuit_excepthook(et,ev,tb): | |
|
63 | def BdbQuit_excepthook(et, ev, tb, excepthook=None): | |
|
64 | """Exception hook which handles `BdbQuit` exceptions. | |
|
65 | ||
|
66 | All other exceptions are processed using the `excepthook` | |
|
67 | parameter. | |
|
68 | """ | |
|
63 | 69 | if et==bdb.BdbQuit: |
|
64 | 70 | print('Exiting Debugger.') |
|
71 | elif excepthook is not None: | |
|
72 | excepthook(et, ev, tb) | |
|
65 | 73 | else: |
|
74 | # Backwards compatibility. Raise deprecation warning? | |
|
66 | 75 | BdbQuit_excepthook.excepthook_ori(et,ev,tb) |
|
67 | 76 | |
|
68 | 77 | def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): |
@@ -108,8 +117,8 b' class Tracer(object):' | |||
|
108 | 117 | ip = get_ipython() |
|
109 | 118 | except NameError: |
|
110 | 119 | # Outside of ipython, we set our own exception hook manually |
|
111 | BdbQuit_excepthook.excepthook_ori = sys.excepthook | |
|
112 | sys.excepthook = BdbQuit_excepthook | |
|
120 | sys.excepthook = functools.partial(BdbQuit_excepthook, | |
|
121 | excepthook=sys.excepthook) | |
|
113 | 122 | def_colors = 'NoColor' |
|
114 | 123 | try: |
|
115 | 124 | # Limited tab completion support |
@@ -136,7 +145,7 b' class Tracer(object):' | |||
|
136 | 145 | except: |
|
137 | 146 | # This is only a user-facing convenience, so any error we encounter |
|
138 | 147 | # here can be warned about but can be otherwise ignored. These |
|
139 |
# printouts will tell us about problems if this API changes |
|
|
148 | # printouts will tell us about problems if this API changes | |
|
140 | 149 | import traceback |
|
141 | 150 | traceback.print_exc() |
|
142 | 151 | |
@@ -423,7 +432,7 b' class Pdb(OldPdb):' | |||
|
423 | 432 | src = [] |
|
424 | 433 | if filename == "<string>" and hasattr(self, "_exec_filename"): |
|
425 | 434 | filename = self._exec_filename |
|
426 | ||
|
435 | ||
|
427 | 436 | for lineno in range(first, last+1): |
|
428 | 437 | line = ulinecache.getline(filename, lineno) |
|
429 | 438 | if not line: |
General Comments 0
You need to be logged in to leave comments.
Login now