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

Method format_stack_entry

Lib/bdb.py:854–882  ·  view source on GitHub ↗

Return a string with information about a stack entry. The stack entry frame_lineno is a (frame, lineno) tuple. The return string contains the canonical filename, the function name or ' ', the input arguments, the return value, and the line of code (if it exis

(self, frame_lineno, lprefix=': ')

Source from the content-addressed store, hash-verified

852 return stack, i
853
854 def format_stack_entry(self, frame_lineno, lprefix=': '):
855 """Return a string with information about a stack entry.
856
857 The stack entry frame_lineno is a (frame, lineno) tuple. The
858 return string contains the canonical filename, the function name
859 or '<lambda>', the input arguments, the return value, and the
860 line of code (if it exists).
861
862 """
863 import linecache, reprlib
864 frame, lineno = frame_lineno
865 filename = self.canonic(frame.f_code.co_filename)
866 s = '%s(%r)' % (filename, lineno)
867 if frame.f_code.co_name:
868 s += frame.f_code.co_name
869 else:
870 s += "<lambda>"
871 s += '()'
872 if '__return__' in frame.f_locals:
873 rv = frame.f_locals['__return__']
874 s += '->'
875 s += reprlib.repr(rv)
876 if lineno is not None:
877 line = linecache.getline(filename, lineno, frame.f_globals)
878 if line:
879 s += lprefix + line.strip()
880 else:
881 s += f'{lprefix}Warning: lineno is None'
882 return s
883
884 def disable_current_event(self):
885 """Disable the current event."""

Callers 2

print_stack_entryMethod · 0.80

Calls 4

canonicMethod · 0.95
reprMethod · 0.45
getlineMethod · 0.45
stripMethod · 0.45

Tested by 1