diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2012-10-18 18:53:28 (GMT) |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2012-10-18 18:53:28 (GMT) |
commit | 44362a88ad8d541c46de0e149975d6a9805b981e (patch) | |
tree | 681dd966f324cf7c288ab4be81466a2637774bf9 /Objects | |
parent | 206f962f32cb537efa115387f3337b28c58006bb (diff) | |
parent | 91044799f7c829404bff2191941f58c8ecbce897 (diff) | |
download | cpython-44362a88ad8d541c46de0e149975d6a9805b981e.zip cpython-44362a88ad8d541c46de0e149975d6a9805b981e.tar.gz cpython-44362a88ad8d541c46de0e149975d6a9805b981e.tar.bz2 |
Issue #16277: merge fix from 3.2
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/longobject.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 06ebeda..87150a9 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -935,6 +935,13 @@ _PyLong_AsByteArray(PyLongObject* v, PyObject * PyLong_FromVoidPtr(void *p) { +#if SIZEOF_VOID_P <= SIZEOF_LONG + /* special-case null pointer */ + if (!p) + return PyLong_FromLong(0); + return PyLong_FromUnsignedLong((unsigned long)(Py_uintptr_t)p); +#else + #ifndef HAVE_LONG_LONG # error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), but no long long" #endif @@ -945,6 +952,7 @@ PyLong_FromVoidPtr(void *p) if (!p) return PyLong_FromLong(0); return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)(Py_uintptr_t)p); +#endif /* SIZEOF_VOID_P <= SIZEOF_LONG */ } |