diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2012-10-18 18:21:43 (GMT) |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2012-10-18 18:21:43 (GMT) |
commit | 91044799f7c829404bff2191941f58c8ecbce897 (patch) | |
tree | c9f4d894b3abe95fa9d0ec016b172f05475c1514 /Objects | |
parent | 5bf7f1f6e39fa399287fea6058c48842c2dd5a3a (diff) | |
download | cpython-91044799f7c829404bff2191941f58c8ecbce897.zip cpython-91044799f7c829404bff2191941f58c8ecbce897.tar.gz cpython-91044799f7c829404bff2191941f58c8ecbce897.tar.bz2 |
Issue #16277: in PyLong_FromVoidPtr, add missing branch for sizeof(void*) <= sizeof(long).
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 b9a0d85..3a675c4 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -926,6 +926,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 @@ -936,6 +943,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 */ } |