[PyQt] Fwd: SIP bug with empty **kwargs on overloaded methods

Phil Thompson phil at riverbankcomputing.com
Sat Feb 14 12:20:54 GMT 2015


On 10/02/2015 1:28 am, Chris Billington wrote:
> A friend of mine hit what looks like a bug in SIP, as outlined in this
> stackoverflow post:
> 
> http://stackoverflow.com/questions/28402234/cannot-wrap-qwebview-load-method
> 
> This appears to be a bug in SIP, which appears to be raising a 
> TypeError
> when it shouldn't. It seems that the existence of **kwargs in the 
> method
> call, even if kwargs is an empty dictionary, trips up some of SIPs 
> error
> checking. The following snippet (also attached) demonstrates this:
> 
>   1
> import sys
>   2
> 
>   3
> from PyQt4 import QtCore
>   4
> from PyQt4 import QtGui
>   5
> 
>   6
> from PyQt4.QtWebKit import QWebView
>   7
> 
>   8
> qapplication = QtGui.QApplication(sys.argv)
>   9
> 
>  10
> webview = QWebView()
>  11
> 
>  12
> url = QtCore.QUrl('http://istonyabbottstillprimeminister.com')
>  13
> 
>  14
> kwargs = {}
>  15
> # webview.load(url, **kwargs) # Doesn't work
>  16
> webview.load(url) # works
>  17
> 
>  18
> webview.show()
>  19
> qapplication.exec_()
> 
> Uncomment line 15 and one gets the following:
> 
> Traceback (most recent call last):
>   File "/home/bilbo/Documents/Scratch/demonstration.py", line 15, in
> <module>
>     webview.load(url, **kwargs) # Doesn't work
> TypeError: QWebView.load(QUrl): argument 1 has unexpected type 'QUrl'
> 
> Even though since kwargs is an empty dictionary, lines 15 and 16 ought 
> to
> be equivalent. I  had a look at the SIP source and was unable to track 
> down
> where the problem might be, though I'm guessing it's in siplib.c.in
> somewhere.
> 
> The problem exists in both Python 2.7 and 3.4, and both PyQt4 and 
> PyQt5.

Should now be fixed in hg.

Thanks,
Phil


More information about the PyQt mailing list