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

Method structured_traceback

IPython/core/ultratb.py:633–704  ·  view source on GitHub ↗

Return a color formatted string with the traceback info. Parameters ---------- etype : exception type Type of the exception raised. evalue : object Data stored in the exception etb : object If list: List of frames, see class do

(self, etype, evalue, etb=None, tb_offset=None,
                             context=5)

Source from the content-addressed store, hash-verified

631 return None
632
633 def structured_traceback(self, etype, evalue, etb=None, tb_offset=None,
634 context=5):
635 """Return a color formatted string with the traceback info.
636
637 Parameters
638 ----------
639 etype : exception type
640 Type of the exception raised.
641
642 evalue : object
643 Data stored in the exception
644
645 etb : object
646 If list: List of frames, see class docstring for details.
647 If Traceback: Traceback of the exception.
648
649 tb_offset : int, optional
650 Number of frames in the traceback to skip. If not given, the
651 instance evalue is used (set in constructor).
652
653 context : int, optional
654 Number of lines of context information to print.
655
656 Returns
657 -------
658 String with formatted exception.
659 """
660 # This is a workaround to get chained_exc_ids in recursive calls
661 # etb should not be a tuple if structured_traceback is not recursive
662 if isinstance(etb, tuple):
663 etb, chained_exc_ids = etb
664 else:
665 chained_exc_ids = set()
666
667 if isinstance(etb, list):
668 elist = etb
669 elif etb is not None:
670 elist = self._extract_tb(etb)
671 else:
672 elist = []
673 tb_offset = self.tb_offset if tb_offset is None else tb_offset
674 Colors = self.Colors
675 out_list = []
676 if elist:
677
678 if tb_offset and len(elist) > tb_offset:
679 elist = elist[tb_offset:]
680
681 out_list.append('Traceback %s(most recent call last)%s:' %
682 (Colors.normalEm, Colors.Normal) + '\n')
683 out_list.extend(self._format_list(elist))
684 # The exception info should be a single entry in the list.
685 lines = ''.join(self._format_exception_only(etype, evalue))
686 out_list.append(lines)
687
688 exception = self.get_parts_of_chained_exception(evalue)
689
690 if exception and not id(exception[1]) in chained_exc_ids:

Callers 7

get_exception_onlyMethod · 0.45
structured_tracebackMethod · 0.45
structured_tracebackMethod · 0.45
structured_tracebackMethod · 0.45
wrappedMethod · 0.45
showtracebackMethod · 0.45
showsyntaxerrorMethod · 0.45

Calls 6

_extract_tbMethod · 0.95
_format_listMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected