Show More
@@ -43,13 +43,14 b' from IPython.testing.skipdoctest import skip_doctest' | |||
|
43 | 43 | |
|
44 | 44 | prompt = 'ipdb> ' |
|
45 | 45 | |
|
46 | #We have to check this directly from sys.argv, config struct not yet available | |
|
46 | # We have to check this directly from sys.argv, config struct not yet available | |
|
47 | 47 | from pdb import Pdb as OldPdb |
|
48 | 48 | |
|
49 | 49 | # Allow the set_trace code to operate outside of an ipython instance, even if |
|
50 | 50 | # it does so with some limitations. The rest of this support is implemented in |
|
51 | 51 | # the Tracer constructor. |
|
52 | 52 | |
|
53 | ||
|
53 | 54 | def make_arrow(pad): |
|
54 | 55 | """generate the leading arrow in front of traceback or debugger""" |
|
55 | 56 | if pad >= 2: |
@@ -67,16 +68,16 b' def BdbQuit_excepthook(et, ev, tb, excepthook=None):' | |||
|
67 | 68 | """ |
|
68 | 69 | warnings.warn("`BdbQuit_excepthook` is deprecated since version 5.1", |
|
69 | 70 | DeprecationWarning, stacklevel=2) |
|
70 | if et==bdb.BdbQuit: | |
|
71 | if et == bdb.BdbQuit: | |
|
71 | 72 | print('Exiting Debugger.') |
|
72 | 73 | elif excepthook is not None: |
|
73 | 74 | excepthook(et, ev, tb) |
|
74 | 75 | else: |
|
75 | 76 | # Backwards compatibility. Raise deprecation warning? |
|
76 | BdbQuit_excepthook.excepthook_ori(et,ev,tb) | |
|
77 | BdbQuit_excepthook.excepthook_ori(et, ev, tb) | |
|
77 | 78 | |
|
78 | 79 | |
|
79 | def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): | |
|
80 | def BdbQuit_IPython_excepthook(self, et, ev, tb, tb_offset=None): | |
|
80 | 81 | warnings.warn( |
|
81 | 82 | "`BdbQuit_IPython_excepthook` is deprecated since version 5.1", |
|
82 | 83 | DeprecationWarning, stacklevel=2) |
@@ -203,7 +204,7 b' class Pdb(OldPdb):' | |||
|
203 | 204 | def __init__(self, color_scheme=None, completekey=None, |
|
204 | 205 | stdin=None, stdout=None, context=5, **kwargs): |
|
205 | 206 | """Create a new IPython debugger. |
|
206 | ||
|
207 | ||
|
207 | 208 | :param color_scheme: Deprecated, do not use. |
|
208 | 209 | :param completekey: Passed to pdb.Pdb. |
|
209 | 210 | :param stdin: Passed to pdb.Pdb. |
@@ -237,7 +238,7 b' class Pdb(OldPdb):' | |||
|
237 | 238 | self.shell = TerminalInteractiveShell.instance() |
|
238 | 239 | # needed by any code which calls __import__("__main__") after |
|
239 | 240 | # the debugger was entered. See also #9941. |
|
240 |
sys.modules['__main__'] = save_main |
|
|
241 | sys.modules['__main__'] = save_main | |
|
241 | 242 | |
|
242 | 243 | if color_scheme is not None: |
|
243 | 244 | warnings.warn( |
@@ -272,7 +273,6 b' class Pdb(OldPdb):' | |||
|
272 | 273 | cst['Neutral'].colors.breakpoint_enabled = C.LightRed |
|
273 | 274 | cst['Neutral'].colors.breakpoint_disabled = C.Red |
|
274 | 275 | |
|
275 | ||
|
276 | 276 | # Add a python parser so we can syntax highlight source while |
|
277 | 277 | # debugging. |
|
278 | 278 | self.parser = PyColorize.Parser(style=color_scheme) |
@@ -326,7 +326,7 b' class Pdb(OldPdb):' | |||
|
326 | 326 | def new_do_quit(self, arg): |
|
327 | 327 | |
|
328 | 328 | if hasattr(self, 'old_all_completions'): |
|
329 | self.shell.Completer.all_completions=self.old_all_completions | |
|
329 | self.shell.Completer.all_completions = self.old_all_completions | |
|
330 | 330 | |
|
331 | 331 | return OldPdb.do_quit(self, arg) |
|
332 | 332 | |
@@ -344,7 +344,7 b' class Pdb(OldPdb):' | |||
|
344 | 344 | if context is None: |
|
345 | 345 | context = self.context |
|
346 | 346 | try: |
|
347 | context=int(context) | |
|
347 | context = int(context) | |
|
348 | 348 | if context <= 0: |
|
349 | 349 | raise ValueError("Context must be a positive integer") |
|
350 | 350 | except (TypeError, ValueError) as e: |
@@ -373,7 +373,7 b' class Pdb(OldPdb):' | |||
|
373 | 373 | if context is None: |
|
374 | 374 | context = self.context |
|
375 | 375 | try: |
|
376 | context=int(context) | |
|
376 | context = int(context) | |
|
377 | 377 | if context <= 0: |
|
378 | 378 | raise ValueError("Context must be a positive integer") |
|
379 | 379 | except (TypeError, ValueError) as e: |
@@ -390,7 +390,7 b' class Pdb(OldPdb):' | |||
|
390 | 390 | if context is None: |
|
391 | 391 | context = self.context |
|
392 | 392 | try: |
|
393 | context=int(context) | |
|
393 | context = int(context) | |
|
394 | 394 | if context <= 0: |
|
395 | 395 | print("Context must be a positive integer", file=self.stdout) |
|
396 | 396 | except (TypeError, ValueError): |
@@ -406,7 +406,7 b' class Pdb(OldPdb):' | |||
|
406 | 406 | tpl_call = u'%s%%s%s%%s%s' % (Colors.vName, Colors.valEm, ColorsNormal) |
|
407 | 407 | tpl_line = u'%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal) |
|
408 | 408 | tpl_line_em = u'%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line, |
|
409 | ColorsNormal) | |
|
409 | ColorsNormal) | |
|
410 | 410 | |
|
411 | 411 | frame, lineno = frame_lineno |
|
412 | 412 | |
@@ -440,7 +440,7 b' class Pdb(OldPdb):' | |||
|
440 | 440 | ret.append('> ') |
|
441 | 441 | else: |
|
442 | 442 | ret.append(' ') |
|
443 | ret.append(u'%s(%s)%s\n' % (link,lineno,call)) | |
|
443 | ret.append(u'%s(%s)%s\n' % (link, lineno, call)) | |
|
444 | 444 | |
|
445 | 445 | start = lineno - 1 - context//2 |
|
446 | 446 | lines = linecache.getlines(filename) |
@@ -448,17 +448,17 b' class Pdb(OldPdb):' | |||
|
448 | 448 | start = max(start, 0) |
|
449 | 449 | lines = lines[start : start + context] |
|
450 | 450 | |
|
451 | for i,line in enumerate(lines): | |
|
451 | for i, line in enumerate(lines): | |
|
452 | 452 | show_arrow = (start + 1 + i == lineno) |
|
453 | 453 | linetpl = (frame is self.curframe or show_arrow) \ |
|
454 | 454 | and tpl_line_em \ |
|
455 | 455 | or tpl_line |
|
456 | 456 | ret.append(self.__format_line(linetpl, filename, |
|
457 | 457 | start + 1 + i, line, |
|
458 |
arrow |
|
|
458 | arrow=show_arrow)) | |
|
459 | 459 | return ''.join(ret) |
|
460 | 460 | |
|
461 |
def __format_line(self, tpl_line, filename, lineno, line, arrow |
|
|
461 | def __format_line(self, tpl_line, filename, lineno, line, arrow=False): | |
|
462 | 462 | bp_mark = "" |
|
463 | 463 | bp_mark_color = "" |
|
464 | 464 | |
@@ -488,7 +488,6 b' class Pdb(OldPdb):' | |||
|
488 | 488 | |
|
489 | 489 | return tpl_line % (bp_mark_color + bp_mark, num, line) |
|
490 | 490 | |
|
491 | ||
|
492 | 491 | def print_list_lines(self, filename, first, last): |
|
493 | 492 | """The printing (as opposed to the parsing part of a 'list' |
|
494 | 493 | command.""" |
@@ -507,9 +506,9 b' class Pdb(OldPdb):' | |||
|
507 | 506 | break |
|
508 | 507 | |
|
509 | 508 | if lineno == self.curframe.f_lineno: |
|
510 |
line = self.__format_line(tpl_line_em, filename, lineno, line, arrow |
|
|
509 | line = self.__format_line(tpl_line_em, filename, lineno, line, arrow=True) | |
|
511 | 510 | else: |
|
512 |
line = self.__format_line(tpl_line, filename, lineno, line, arrow |
|
|
511 | line = self.__format_line(tpl_line, filename, lineno, line, arrow=False) | |
|
513 | 512 | |
|
514 | 513 | src.append(line) |
|
515 | 514 | self.lineno = lineno |
@@ -706,7 +705,7 b' class Pdb(OldPdb):' | |||
|
706 | 705 | |
|
707 | 706 | Will skip hidden frames. |
|
708 | 707 | """ |
|
709 |
|
|
|
708 | # modified version of upstream that skips | |
|
710 | 709 | # frames with __tracebackide__ |
|
711 | 710 | if self.curindex == 0: |
|
712 | 711 | self.error("Oldest frame") |
General Comments 0
You need to be logged in to leave comments.
Login now