[PyQt] Bug in sip.voidptr?
nathan at genarts.com
Fri Dec 10 20:56:23 GMT 2010
I think I've found a bug when constructing sip.voidptr from an integer.
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.
Centos 5 (64-bit)
Python 2.6.6 (32-bit)
. . . . . . . . . . . . . . . . . . . . . . . . .
Nathan Weston nathan at genarts.com
GenArts, Inc. Tel: 617-492-2888
955 Mass. Ave Fax: 617-492-2852
Cambridge, MA 02139 USA www.genarts.com
More information about the PyQt