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

Function extract_stack

Lib/traceback.py:261–274  ·  view source on GitHub ↗

Extract the raw traceback from the current stack frame. The return value has the same format as for extract_tb(). The optional 'f' and 'limit' arguments have the same meaning as for print_stack(). Each item in the list is a quadruple (filename, line number, function name, text), a

(f=None, limit=None)

Source from the content-addressed store, hash-verified

259
260
261def extract_stack(f=None, limit=None):
262 """Extract the raw traceback from the current stack frame.
263
264 The return value has the same format as for extract_tb(). The
265 optional 'f' and 'limit' arguments have the same meaning as for
266 print_stack(). Each item in the list is a quadruple (filename,
267 line number, function name, text), and the entries are in order
268 from oldest to newest stack frame.
269 """
270 if f is None:
271 f = sys._getframe().f_back
272 stack = StackSummary.extract(walk_stack(f), limit=limit)
273 stack.reverse()
274 return stack
275
276
277def clear_frames(tb):

Callers 3

doTracebackMethod · 0.90
print_stackFunction · 0.70
format_stackFunction · 0.70

Calls 3

walk_stackFunction · 0.85
extractMethod · 0.45
reverseMethod · 0.45

Tested by 1

doTracebackMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…