[英]How to debug ignored exception in python
我的(python 2.7)程序退出时,我遇到了很多被忽略的异常。 但是由于项目规模很大,并且基于其他人开发的项目,因此很难使用此类信息来定位错误。 有没有什么方法可以获取异常跟踪,或者任何其他可以帮助您的方法? 谢谢。
Exception TypeError: "'NoneType' object is not callable" in <object repr() failed> ignored
Exception TypeError: "'NoneType' object is not callable" in <object repr() failed> ignored
Exception TypeError: "'NoneType' object is not callable" in <object repr() failed> ignored
...
Exception TypeError: "'NoneType' object is not callable" in <object repr() failed> ignored
您可以运行:
$ python -v your_file.py
我将在代码库中扫描与输出匹配的字符串。 像Exception .* ignored
类的东西Exception .* ignored
因为异常和对象信息可能正在格式化变量。 这应该找到生成输出的语句。
找到这些语句后,假设它们位于try / except块内,则可以使用traceback模块中的工具打印回溯,或者,如果正在使用日志记录包,则将关键字参数exc_info=True
传递给日志方法 。
还值得扫描以查看sys.excepthook是否被覆盖。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.