From 49b4a386c3730b7ee79c2e2233c8fa559278be75 Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Fri, 6 Feb 2009 12:29:32 -0200 Subject: [PATCH] fix type conversion functions involving PY_LONG_LONG for Python 3 --- Cython/Compiler/PyrexTypes.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 { -- 2.26.2