MCPcopy Index your code
hub / github.com/python/cpython / format_stack_entry

Method format_stack_entry

Lib/bdb.py:845–873  ·  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

843 return stack, i
844
845 def format_stack_entry(self, frame_lineno, lprefix=': '):
846 """Return a string with information about a stack entry.
847
848 The stack entry frame_lineno is a (frame, lineno) tuple. The
849 return string contains the canonical filename, the function name
850 or '<lambda>', the input arguments, the return value, and the
851 line of code (if it exists).
852
853 """
854 import linecache, reprlib
855 frame, lineno = frame_lineno
856 filename = self.canonic(frame.f_code.co_filename)
857 s = '%s(%r)' % (filename, lineno)
858 if frame.f_code.co_name:
859 s += frame.f_code.co_name
860 else:
861 s += "<lambda>"
862 s += '()'
863 if '__return__' in frame.f_locals:
864 rv = frame.f_locals['__return__']
865 s += '->'
866 s += reprlib.repr(rv)
867 if lineno is not None:
868 line = linecache.getline(filename, lineno, frame.f_globals)
869 if line:
870 s += lprefix + line.strip()
871 else:
872 s += f'{lprefix}Warning: lineno is None'
873 return s
874
875 def disable_current_event(self):
876 """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