Switch modes for the exception handlers. Valid modes: Plain, Context, Verbose, and Minimal. If called without arguments, acts as a toggle. When in verbose mode the value --show (and --hide) will respectively show (or hide) frames with ``__tracebackhide__ =
(self, parameter_s='')
| 360 | |
| 361 | @line_magic |
| 362 | def xmode(self, parameter_s=''): |
| 363 | """Switch modes for the exception handlers. |
| 364 | |
| 365 | Valid modes: Plain, Context, Verbose, and Minimal. |
| 366 | |
| 367 | If called without arguments, acts as a toggle. |
| 368 | |
| 369 | When in verbose mode the value --show (and --hide) |
| 370 | will respectively show (or hide) frames with ``__tracebackhide__ = |
| 371 | True`` value set. |
| 372 | """ |
| 373 | |
| 374 | def xmode_switch_err(name): |
| 375 | warn('Error changing %s exception modes.\n%s' % |
| 376 | (name,sys.exc_info()[1])) |
| 377 | |
| 378 | shell = self.shell |
| 379 | if parameter_s.strip() == "--show": |
| 380 | shell.InteractiveTB.skip_hidden = False |
| 381 | return |
| 382 | if parameter_s.strip() == "--hide": |
| 383 | shell.InteractiveTB.skip_hidden = True |
| 384 | return |
| 385 | |
| 386 | new_mode = parameter_s.strip().capitalize() |
| 387 | try: |
| 388 | shell.InteractiveTB.set_mode(mode=new_mode) |
| 389 | print('Exception reporting mode:',shell.InteractiveTB.mode) |
| 390 | except: |
| 391 | xmode_switch_err('user') |
| 392 | |
| 393 | @line_magic |
| 394 | def quickref(self, arg): |