[PyQt] Old SIP bug reemerging?

Phil Thompson phil at riverbankcomputing.co.uk
Wed May 23 20:24:52 BST 2007

On Wednesday 23 May 2007 1:47 pm, Mikael Schönenberg wrote:
> Way back in late 2004 Fredrik, a colleague of mine, reported a
> problem[1] that eventually turned out to be a bug[2] in SIP 4.1.1,
> which we were using at the time. Phil, as always, resolved the issue
> more or less immediately after the source of the error had been
> located.
> However, after recently upgrading to SIP 4.6 we started to experience
> problems that look very similar to the ones we had back then, so I
> decided to dig up Fredrik's old test application[3] and run it on our
> current environment (Python 2.5, Qt 3.3.4, PyQt 3.17.1, SIP 4.6). As
> expected, it indicates that the bug has come back - or that a new
> and similar one is there instead.
> The problem in itself is that SIP/PyQt sometimes gets confused about
> what class an object has. The symptom in the test scripts is that
> widgets we know are QLabels are considered by SIP/PyQt to be QWidgets,
> and thus QLabel specific attributes will not be present.
> I am supplying a slightly modified version of Fredrik's original test
> application with this mail. The modifications consist of:
> - A couple of print statements that tells you what versions of Qt,
>   PyQt and SIP you're running.
> - A minor patch to an iteration needed since QWidget.children()
>   nowadays return None rather than an empty list if a widget has no
>   children.
> The application creates a large number of labels, and gives you a
> button to press to destroy and recreate all of them. Given sufficient
> amount of clicks on the button, the bug will (probably) be
> provoked. An Auto-redraw check box can be ticked to have the
> application simulate a button click once every hundred
> milliseconds. Tick it, wait sufficiently long (generally less than a
> minute for me) and see the tracebacks start spamming...
> It should be pointed out that I don't really have anything indicating
> that the problem we're experiencing now is in any way related to the
> one reported back in 2004. However, as the symptoms are similar and
> the same test case can be used to demonstrate the problem, I thought
> it might be worth mentioning the previous discussion about it.
> I must admit that I have not been paying very close attention to this
> list lately, so if this problem has been reported recently, I
> apologise for wasting your time.
> [1]
> http://www.riverbankcomputing.com/pipermail/pyqt/2004-November/009008.html
> [2]
> http://www.riverbankcomputing.com/pipermail/pyqt/2004-November/009070.html
> [3]
> http://www.riverbankcomputing.com/pipermail/pyqt/2004-November/009021.html

It is basically the same problem - sip can't tell if two instances at the same 
address are the same or if the memory has been reused. Note that it will 
always be possible to fool sip in to making the wrong choice - it's a 
question of getting it to make the right choice in the majority of cases.

A fix will be in tonight's snapshot - it simply removes a test. My only 
concern is if the test was in there for a good reason or not. I'm hoping that 
improvements in the way sub-class converters work mean that the test is no 
longer appropriate.


More information about the PyQt mailing list