Switch modes for the exception handlers. Valid modes: Plain, Context, Verbose, Minimal, Docs, and Doctest. - ``Plain``: similar to Python's default traceback. - ``Context``: shows several lines of surrounding context for each frame in the traceback. - ``Ve
(self, parameter_s='')
| 342 | |
| 343 | @line_magic |
| 344 | def xmode(self, parameter_s=''): |
| 345 | """Switch modes for the exception handlers. |
| 346 | |
| 347 | Valid modes: Plain, Context, Verbose, Minimal, Docs, and Doctest. |
| 348 | |
| 349 | - ``Plain``: similar to Python's default traceback. |
| 350 | - ``Context``: shows several lines of surrounding context for each |
| 351 | frame in the traceback. |
| 352 | - ``Verbose``: like Context, but also displays local variable values |
| 353 | in each frame. |
| 354 | - ``Minimal``: shows only the exception type and message, without |
| 355 | a traceback. |
| 356 | - ``Docs``: a stripped-down version of Verbose, designed for use |
| 357 | when running doctests. |
| 358 | - ``Doctest``: shows only the traceback header, an ellipsis, and the |
| 359 | exception line, for easy copy-paste into Python doctests. |
| 360 | |
| 361 | If called without arguments, cycles through the available modes. |
| 362 | |
| 363 | When in verbose mode the value ``--show`` (and ``--hide``) |
| 364 | will respectively show (or hide) frames with ``__tracebackhide__ = |
| 365 | True`` value set. |
| 366 | """ |
| 367 | |
| 368 | def xmode_switch_err(name): |
| 369 | warn('Error changing %s exception modes.\n%s' % |
| 370 | (name,sys.exc_info()[1])) |
| 371 | |
| 372 | shell = self.shell |
| 373 | if parameter_s.strip() == "--show": |
| 374 | shell.InteractiveTB.skip_hidden = False |
| 375 | return |
| 376 | if parameter_s.strip() == "--hide": |
| 377 | shell.InteractiveTB.skip_hidden = True |
| 378 | return |
| 379 | |
| 380 | new_mode = parameter_s.strip().capitalize() |
| 381 | try: |
| 382 | shell.InteractiveTB.set_mode(mode=new_mode) |
| 383 | print('Exception reporting mode:',shell.InteractiveTB.mode) |
| 384 | except: |
| 385 | raise |
| 386 | xmode_switch_err('user') |
| 387 | |
| 388 | @line_magic |
| 389 | def quickref(self, arg): |