strange issue with C extension using Py_BuildValue
Mark Hammond
skippy.hammond at gmail.com
Wed Feb 10 20:24:30 EST 2010
On 11/02/2010 9:19 AM, bobicanprogram wrote:
> I'm am having "strange" problems with the code snip below.
>
> When this code is built on a 64bit Linux, it would appear to work
> flawlessly. When the source is rebuilt on a 32bit Linux it begins
> to crack in strange ways. The issue seems to be associated with the
> sender field in the Py_BuildValue call. The fact that sender is a
> pointer should mean that its value is an unsigned integer. However,
> on the 32 bit build the failure is that the msgPtr->data value is
> "messed up". If the format associated with the sender (a pointer)
> from "L" to "i" things work on the 32 bit side but break on the 64 bit
> side.
I expect that in a 32bit build of linux, a "long long" (the 'L' format)
is still 64 bits. You probably want something like:
Py_BuildValue("iNz#", ret, PyLong_FromVoidPtr(sender), &msgPtr->data, ret);
and PyLong_AsVoidPtr() for the other direction.
HTH,
Mark
More information about the Python-list
mailing list