[PyQt] Exceptions in Python Implementations of Virtuals

Kovid Goyal kovid at kovidgoyal.net
Tue Sep 30 18:26:01 BST 2014

Aborting on all unhandled exceptions in python callbacks will be a huge
behavior change. I dont think it is one you can make lightly. Certainly
not in a minor release.

My original proposal for using qFatal() is simply in cases where you
already *know* that Qt will segfault because of the unhandled exception.
In such cases, qFatal() with an informative error is much nicer.

Regarding the general question of what to do with exceptions in python
callbacks, I think it should be left upto the application developer. One
possible mechanism would be to store the exceptions in a global variable
(say limited to the last 100 exceptions) and let the application
developer deal with them as he thinks appropriate.


On Tue, Sep 30, 2014 at 05:23:08PM +0100, Phil Thompson wrote:
> Florian asked this question but it didn't result in any discussion, so I'd
> like to have another poke at it.
> Currently, if an exception is raised by a Python re-implementation of a C++
> virtual then the exception is printed and the application continues. A
> default result will be constructed by PyQt and returned to C++. Instead,
> should PyQt print the exception and then terminate (by calling qFatal())?
> Some advantages...
> - consistency in what happens when an unhandled exception is raised (ie. the
> application always terminates)
> - such bugs become obvious and easy to find
> Some disadvantages...
> - incompatible with current behaviour
> - may cause problems with applications that already try to handle such
> exceptions using exception hooks
> If I make this change it will be for PyQt5 only. I don't plan to make the
> change configurable in any way.
> Comments?
> Phil
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> !DSPAM:3,542ad90916651154510818!


Dr. Kovid Goyal 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140930/9bcdcfff/attachment.sig>

More information about the PyQt mailing list