def extract_tb(tb, limit=None):
"""This implementation is stolen from traceback module but respects __traceback_hide__."""
if limit is None:
if hasattr(sys, 'tracebacklimit'):
limit = sys.tracebacklimit
tb_list = []
n = 0
while tb is not None and (limit is None or n < limit):
f = tb.tb_frame
if not _should_skip_frame(f):
lineno = tb.tb_lineno
co = f.f_code
filename = co.co_filename
name = co.co_name
linecache.checkcache(filename)
line = linecache.getline(filename, lineno, f.f_globals)
if line:
line = line.strip()
else:
line = None
tb_list.append((filename, lineno, name, line))
tb = tb.tb_next
n = n + 1
return tb_list
评论列表
文章目录