mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Issue #16277: merge fix from 3.3
This commit is contained in:
commit
5cb65917e1
1 changed files with 8 additions and 0 deletions
|
|
@ -935,6 +935,13 @@ _PyLong_AsByteArray(PyLongObject* v,
|
||||||
PyObject *
|
PyObject *
|
||||||
PyLong_FromVoidPtr(void *p)
|
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
|
#ifndef HAVE_LONG_LONG
|
||||||
# error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), but no long long"
|
# error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), but no long long"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -945,6 +952,7 @@ PyLong_FromVoidPtr(void *p)
|
||||||
if (!p)
|
if (!p)
|
||||||
return PyLong_FromLong(0);
|
return PyLong_FromLong(0);
|
||||||
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)(Py_uintptr_t)p);
|
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)(Py_uintptr_t)p);
|
||||||
|
#endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue