纯Python没有提供一种方法来变异现有的追溯对象或创建任意的追溯对象。
>>> exc_info[2].tb_next = NoneTraceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: readonly attribute>>> types.TracebackType()Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: cannot create 'traceback' instances
请注意,如果有可能做到这一点,您不仅会影响回溯的默认格式,还会干扰人们使用pdb在实用程序模块中进行事后检查错误的能力。
如果您的实用程序模块正在记录回溯或以其他方式格式化了回溯,那么您仅可以在输出中不包含您认为不感兴趣的帧。例如,
unittest当报告运行测试时发生的错误时,标准库的模块会执行此操作。


![引发异常而在追溯中不“引发”?[重复] 引发异常而在追溯中不“引发”?[重复]](http://www.mshxw.com/aiimages/31/398395.png)
