def print_exception():
# count the debugger frames to be removed
tb = traceback.extract_tb(sys.exc_info()[2])
debugger_count = len(tb)
while debugger_count:
if is_same_py_file(tb[debugger_count - 1][0], __file__):
break
debugger_count -= 1
# print the traceback
tb = tb[debugger_count:]
if tb:
print('Traceback (most recent call last):')
for out in traceback.format_list(tb):
sys.stdout.write(out)
# print the exception
for out in traceback.format_exception_only(sys.exc_info()[0], sys.exc_info()[1]):
sys.stdout.write(out)
评论列表
文章目录