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

Chris Billington chrisjbillington at gmail.com
Tue Feb 10 01:28:43 GMT 2015


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.

Regards,

Chris Billington
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150210/002cadba/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demonstration.py
Type: text/x-python
Size: 350 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150210/002cadba/attachment.py>


More information about the PyQt mailing list