Print the last traceback. Optionally, specify an exception reporting mode, tuning the verbosity of the traceback. By default the currently-active exception mode is used. See %xmode for changing exception reporting modes. Valid modes: Plain, Context, Verbose, and Min
(self, s)
| 508 | |
| 509 | @line_magic |
| 510 | def tb(self, s): |
| 511 | """Print the last traceback. |
| 512 | |
| 513 | Optionally, specify an exception reporting mode, tuning the |
| 514 | verbosity of the traceback. By default the currently-active exception |
| 515 | mode is used. See %xmode for changing exception reporting modes. |
| 516 | |
| 517 | Valid modes: Plain, Context, Verbose, and Minimal. |
| 518 | """ |
| 519 | interactive_tb = self.shell.InteractiveTB |
| 520 | if s: |
| 521 | # Switch exception reporting mode for this one call. |
| 522 | # Ensure it is switched back. |
| 523 | def xmode_switch_err(name): |
| 524 | warn('Error changing %s exception modes.\n%s' % |
| 525 | (name,sys.exc_info()[1])) |
| 526 | |
| 527 | new_mode = s.strip().capitalize() |
| 528 | original_mode = interactive_tb.mode |
| 529 | try: |
| 530 | try: |
| 531 | interactive_tb.set_mode(mode=new_mode) |
| 532 | except Exception: |
| 533 | xmode_switch_err('user') |
| 534 | else: |
| 535 | self.shell.showtraceback() |
| 536 | finally: |
| 537 | interactive_tb.set_mode(mode=original_mode) |
| 538 | else: |
| 539 | self.shell.showtraceback() |
| 540 | |
| 541 | @skip_doctest |
| 542 | @line_magic |
nothing calls this directly
no test coverage detected