Message188111
"PyLong_FromVoidPtr works for uintptr_t, but not intptr_t."
Ok correct. You should use something like:
PyObject*
PyLong_FromIntptr_t(intptr_t value)
{
if (sizeof(intptr_t) == sizeof(long))
return PyLong_FromLong(value);
else {
assert(sizeof(intptr_t) <= sizeof(PY_LONG_LONG));
return PyLong_FromLongLong((PY_LONG_LONG)value);
}
}
The "if (sizeof(intptr_t) == sizeof(long))" should be optimized by your compiler.
I don't know if Python should provide such function. What is your use case for intptr_t?
It looks like intptr_t is only really used in the implementation of os.spawnv() and os.spawnve(). Extract:
#if SIZEOF_LONG == SIZEOF_VOID_P
return Py_BuildValue("l", (long) spawnval);
#else
return Py_BuildValue("L", (PY_LONG_LONG) spawnval);
#endif |
|
Date |
User |
Action |
Args |
2013-04-29 22:00:07 | vstinner | set | recipients:
+ vstinner, Devin Jeanpierre |
2013-04-29 22:00:07 | vstinner | set | messageid: <1367272807.19.0.017827588523.issue17870@psf.upfronthosting.co.za> |
2013-04-29 22:00:07 | vstinner | link | issue17870 messages |
2013-04-29 22:00:06 | vstinner | create | |
|