[PyQt] Roadmap suggestion: raise exception when connect() fails

Phil Thompson phil at riverbankcomputing.com
Tue Jan 27 17:07:57 GMT 2009


On Wed, 21 Jan 2009 19:58:06 +0100, Giovanni Bajo <rasky at develer.com>
wrote:
> Hello,
> 
> a problem that often arise when programming with PyQt is that 
> QObject.connect() simply returns False when a connection fails. 
> Sometimes you get some debug output on the console (coming from Qt), but 
> this is not true if the reason why the connection fails is a 
> PyQt-specific one.
> 
> An example is signal forwarding when the first signal is a short-circuit 
> signal. This is not supported by PyQt, but what happens is that 
> QObject.connect() simply returns False, and you get no other feedback 
> that your connection is wrong.
> 
> I believe that it would be worth to special-case the binding of 
> QObject.connect() so that, when a connection fails, a RuntimeError is 
> raised. I think it's a function that it is very common *and* it has a 
> deep semantic overloading in PyQt (that is, it's behaviour is much more 
> complex than the basic Qt's connect() because of additional features 
> like PyQt_PyObject, short-circuit signals, etc.).

I will consider this if it can be done very easily after all the other
refactoring has been done. I don't want to risk breaking existing
applications, even though it might highlight bugs in those applications.

> I would of course recommend to do the same for pyqtBoundSignal.connect().

Definately - any failure in a new-style connection will raise an exception.

Phil


More information about the PyQt mailing list