[PyQt] SIP: rich compare with a tuple bug?
Kevin Watters
kevin at digsby.com
Wed Apr 23 20:27:50 BST 2008
I think I found a bug with rich comparison operators. I have a simple class
like this:
class point
{
public:
point();
point(int x, int y);
int x;
int y;
%ConvertToTypeCode
/* (convert sequences with 2 ints to points) */
%End
bool operator==(const point&);
};
The ConvertToTypeCode successfully makes it so that any function expecting a
point object will take a 2-tuple (or 2 integer sequence of any type) just fine.
But I'm having problems with the operator== -- it doesn't work for tuples.
>From Python:
p = point(42, 5)
p == (42, 5) # False
If I step into my ConvertToTypeCode, I see that sipPy is only getting the first
integer in the tuple. So this actually works:
p = point(42, 5)
p == ((42, 5), ) # True
But strangely, if I use any other sequence than a tuple, it appears to work
fine:
p = point(42, 5)
p == [42, 5] # True
So that leads me to believe that somewhere we're missing a PyTuple_New in SIP.
I can't quite figure out where in the SIP source this should be happening,
though.
All of the relevant code is in this pastebin: http://pastebin.org/31587
Thanks for any help!
More information about the PyQt
mailing list