MCPcopy Create free account
hub / github.com/ipython/ipython / xmode

Method xmode

IPython/core/magics/basic.py:362–391  ·  view source on GitHub ↗

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='')

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 1

set_modeMethod · 0.80

Tested by

no test coverage detected