[PyQt] Exceptions in Python Implementations of Virtuals

Florian Bruhin me at the-compiler.org
Wed Oct 1 10:03:48 BST 2014


* Phil Thompson <phil at riverbankcomputing.com> [2014-10-01 09:31:26 +0100]:
> On 01/10/2014 9:05 am, Florian Bruhin wrote:
> >* Phil Thompson <phil at riverbankcomputing.com> [2014-10-01 08:53:10 +0100]:
> >>Of course qFatal() only aborts the application if you are using the
> >>default
> >>message handler. There is nothing to stop you doing exactly what you
> >>would
> >>do with sys.excepthook and you would also catch any calls from within
> >>Qt.
> >
> >If this can easily be overrided by setting sys.excepthook, big +1 for
> >it from me.
> >
> >Applications with a custom exception handler won't break, and
> >applications without a handler (which are already broken) will fail
> >loudly rather than silently, just like anything else in Python.
> >
> >Still I think qFatal should be used (even when sys.excepthook is set)
> >in the few places known to cause segfaults otherwise. An exception
> >message and qFatal is still better than a segfault without any message
> >(and random coredump).
> 
> So...
> 
> For all exceptions raised by virtual reimplementations (and slots connected
> to signals) PyQt will invoke an error handler that will check if
> sys.excepthook has been modified. If it has been modified then it does
> nothing, otherwise it calls qFatal(). That should mean that "good"
> applications continue to work without changes.
> 
> It will be possible to specify (in the .sip file) that an individual virtual
> must not raise an unhandled exception. This would be implemented by
> explicitly calling abort() after calling the error handler.

Sounds perfect to me.

What version do you plan to add this to? IMHO this is something which
could be added to a minor version (as said - good applications will
continue to work), but I also see why such a big change wouldn't be
added to a minor release.

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
             GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141001/d16f615c/attachment.sig>


More information about the PyQt mailing list