A Major QtExceptHook Update

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 TracebackException to 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.
  • Qt’s QCommandLineParser is now used to provide a --report-button option 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.

Enjoy. 🙂

CC BY-SA 4.0 A Major QtExceptHook Update by Stephan Sokolow is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

This entry was posted in Geek Stuff. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution under the same terms as the associated post.

All comments are moderated. If your comment is generic enough to apply to any post, it will be assumed to be spam. Borderline comments will have their URL field erased before being approved.