For anyone who uses
QtExceptHook, my port of the old
gtkexcepthook.py script to PyQt5, I have an announcement I think you’ll appreciate… I just made a major update.
If you don’t use
QtExceptHook, it’s a single Python file you can drop into your PyQt5 projects so that uncaught exceptions will appear as a user-friendly dialog box which harvests both the traceback and all the local variables at each level of the call stack. It also has your choice of a “copy to clipboard” button or a “report bug” button which invokes a traceback-sending callback of your choice.
…so, what features did I add?
- In exchange for bumping the minimum Python version to 3.5, it now relies on the Python standard library’s
TracebackExceptionto generate the traceback and variable dumps, removing all the most opaque code I inherited and massively reducing the surface area for bugs that might not show up under basic testing.
- It’s now fully documented in Sphinx-dialect ReStructuredText, in case you want to expose it in your API documentation. (Though it does assume you’ll be using the sphinx-autodoc-typehints and sphinx-qt-documentation extensions.)
- The dialog is now resizable and the traceback preview now scrolls horizontally instead of wrapping.
- I did a major refactoring of the Qt-specific parts of the script to make them simpler and more readable.
- The example SMTP bug-reporting code now has error handling.
QCommandLineParseris now used to provide a
--report-buttonoption so you can run the demo code both with and without a bug-reporting callback without having to edit the file.
- The file is now TODO-free.