From f913f4d3d0a95a6ff293e5b3af3983683a0eab1c Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 9 Mar 2013 14:18:55 +0100 Subject: [PATCH] streamline __Pyx_PyInt_AsSize_t() a bit --- Cython/Utility/TypeConversion.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c index 81fe6fa..92b55ef 100644 --- a/Cython/Utility/TypeConversion.c +++ b/Cython/Utility/TypeConversion.c @@ -280,11 +280,10 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); - if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) { - return (size_t)-1; - } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); + if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { + if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); return (size_t)-1; } return (size_t)val; -- 2.7.4