def print_exception(exc_type, exc_value, exc_tb):
# remove debugger frames from the top and bottom of the traceback
tb = traceback.extract_tb(exc_tb)
for i in [0, -1]:
while tb:
frame_file = path.normcase(tb[i][0])
if not any(is_same_py_file(frame_file, f) for f in DONT_DEBUG):
break
del tb[i]
# print the traceback
if tb:
print('Traceback (most recent call last):')
for out in traceback.format_list(tb):
sys.stderr.write(out)
# print the exception
for out in traceback.format_exception_only(exc_type, exc_value):
sys.stdout.write(out)
评论列表
文章目录