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