簡體   English   中英

如何在python中調試忽略的異常

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM