On Fri, 10 Dec 2010 15:56:23 -0500, Nathan Weston <nat...@genarts.com> wrote: > I think I've found a bug when constructing sip.voidptr from an integer. > This statement: > sip.voidptr(2**31) > > raises an exception: TypeError: a single integer, Capsule, CObject, None
> or another voidptr is required > > The problem appears to be at voidptr.c:568 > ptr = (void *)PyInt_AsLong(arg) > > Python integers are signed, so 2**31 isn't a valid int (even though it's > a valid 32-bit pointer), thus the cast fails. Values smaller than 2**31 > work fine. I was able to fix the problem by changing the cast to this: > > ptr = (void *)PyLong_AsUnsignedLong(arg); > > I'm not sure if this handles all overflows correctly (since a Python > long can be larger than 2**32), but it works for me. > > > Versions: > Centos 5 (64-bit) > Python 2.6.6 (32-bit) > sip 4.11.1 I've changed it to use PyLong_AsVoidPtr() which (for some reason) I had thought was Python v3 only. Thanks, Phil _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt