简体   繁体   中英

How to debug ignored exception in python

I got a lot of ignored exceptions when my (python 2.7) program exits. But since the project scale is large, and based on a project developed by others, it's hard to locate the bug with such info. Is there any way to get the exception trace, or any other methods that can help? Thanks.

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

I would scan the codebase for strings that match the output. Something like Exception .* ignored as the exception and object information are likely to be formatting variables. This should find the statements that generate the output.

Once you have found these statements, assuming that they are inside a try / except block you can use the tools in the traceback module to print the tracebacks, or, if the logging package is being used, pass the keyword argument exc_info=True to the log method .

It's also worth scanning to see if sys.excepthook is being overridden.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM