Commit 49b4a386 authored by Lisandro Dalcin's avatar Lisandro Dalcin

fix type conversion functions involving PY_LONG_LONG for Python 3

parent 7abeaf17
...@@ -1403,10 +1403,13 @@ static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { ...@@ -1403,10 +1403,13 @@ static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
} }
static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) { static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
if (PyInt_CheckExact(x)) { if (PyInt_CheckExact(x)) {
return PyInt_AS_LONG(x); return PyInt_AS_LONG(x);
} }
else if (PyLong_CheckExact(x)) { else
#endif
if (PyLong_CheckExact(x)) {
return PyLong_AsLongLong(x); return PyLong_AsLongLong(x);
} }
else { else {
...@@ -1419,6 +1422,7 @@ static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) { ...@@ -1419,6 +1422,7 @@ static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
} }
static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) { static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
if (PyInt_CheckExact(x)) { if (PyInt_CheckExact(x)) {
long val = PyInt_AS_LONG(x); long val = PyInt_AS_LONG(x);
if (unlikely(val < 0)) { if (unlikely(val < 0)) {
...@@ -1427,7 +1431,9 @@ static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) ...@@ -1427,7 +1431,9 @@ static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x)
} }
return val; return val;
} }
else if (PyLong_CheckExact(x)) { else
#endif
if (PyLong_CheckExact(x)) {
return PyLong_AsUnsignedLongLong(x); return PyLong_AsUnsignedLongLong(x);
} }
else { else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment