您可以安装自己的异常挂钩,并从那里输出所需的内容:
import sys, tracebackdef excepthook(type, value, tb): traceback.print_exception(type, value, tb) while tb.tb_next: tb = tb.tb_next print >>sys.stderr, 'Locals:', tb.tb_frame.f_locals print >>sys.stderr, 'Globals:', tb.tb_frame.f_globalssys.excepthook = excepthookdef x(): y()def y(): foo = 1 bar = 0 foo/barx()
while tb: print >>sys.stderr, 'Locals:', tb.tb_frame.f_locals print >>sys.stderr, 'Globals:', tb.tb_frame.f_globals tb = tb.tb_next
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)