From: Lisandro Dalcin Date: Fri, 6 Feb 2009 14:29:32 +0000 (-0200) Subject: fix type conversion functions involving PY_LONG_LONG for Python 3 X-Git-Tag: 0.11.rc~93^2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=49b4a386c3730b7ee79c2e2233c8fa559278be75;p=cython.git fix type conversion functions involving PY_LONG_LONG for Python 3 --- diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index efc0124f..15b8fa3e 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -1403,10 +1403,13 @@ static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { } static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) { +#if PY_VERSION_HEX < 0x03000000 if (PyInt_CheckExact(x)) { return PyInt_AS_LONG(x); } - else if (PyLong_CheckExact(x)) { + else +#endif + if (PyLong_CheckExact(x)) { return PyLong_AsLongLong(x); } else { @@ -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) { +#if PY_VERSION_HEX < 0x03000000 if (PyInt_CheckExact(x)) { long val = PyInt_AS_LONG(x); if (unlikely(val < 0)) { @@ -1427,7 +1431,9 @@ static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) } return val; } - else if (PyLong_CheckExact(x)) { + else +#endif + if (PyLong_CheckExact(x)) { return PyLong_AsUnsignedLongLong(x); } else {