MCPcopy Index your code
hub / github.com/ipython/ipython / format_stack_entry

Method format_stack_entry

IPython/core/debugger.py:671–775  ·  view source on GitHub ↗

overwrite from super class so must -> str

(
        self,
        frame_lineno: tuple[FrameType, int],  # type: ignore[override] # stubs are wrong
        lprefix: str = ": ",
    )

Source from the content-addressed store, hash-verified

669 return frame.f_locals
670
671 def format_stack_entry(
672 self,
673 frame_lineno: tuple[FrameType, int], # type: ignore[override] # stubs are wrong
674 lprefix: str = ": ",
675 ) -> str:
676 """
677 overwrite from super class so must -> str
678 """
679 context = self.context
680 try:
681 context = int(context)
682 if context <= 0:
683 print("Context must be a positive integer", file=self.stdout)
684 except (TypeError, ValueError):
685 print("Context must be a positive integer", file=self.stdout)
686
687 import reprlib
688
689 ret_tok = []
690
691 frame, lineno = frame_lineno
692
693 return_value = ""
694 loc_frame = self._get_frame_locals(frame)
695 if "__return__" in loc_frame:
696 rv = loc_frame["__return__"]
697 # return_value += '->'
698 return_value += reprlib.repr(rv) + "\n"
699 ret_tok.extend([(Token, return_value)])
700
701 # s = filename + '(' + `lineno` + ')'
702 filename = self.canonic(frame.f_code.co_filename)
703 link_tok = (Token.FilenameEm, filename)
704
705 if frame.f_code.co_name:
706 func = frame.f_code.co_name
707 else:
708 func = "<lambda>"
709
710 call_toks = []
711 if func != "?":
712 if "__args__" in loc_frame:
713 args = reprlib.repr(loc_frame["__args__"])
714 else:
715 args = "()"
716 call_toks = [(Token.VName, func), (Token.ValEm, args)]
717
718 # The level info should be generated in the same format pdb uses, to
719 # avoid breaking the pdbtrack functionality of python-mode in *emacs.
720 if frame is self.curframe:
721 ret_tok.append((Token.CurrentFrame, self.theme.make_arrow(2)))
722 else:
723 ret_tok.append((Token, " "))
724
725 ret_tok.extend(
726 [
727 link_tok,
728 (Token, "("),

Callers 2

print_stack_traceMethod · 0.95
print_stack_entryMethod · 0.95

Calls 4

_get_frame_localsMethod · 0.95
__line_contentMethod · 0.95
make_arrowMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected