Commit 92a00f06 authored by Stefan Behnel's avatar Stefan Behnel

move error handling code out of fast path

parent da0c047c
...@@ -1404,11 +1404,6 @@ static CYTHON_INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x ...@@ -1404,11 +1404,6 @@ static CYTHON_INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x
#endif #endif
if (likely(PyLong_Check(x))) { if (likely(PyLong_Check(x))) {
if (is_unsigned) { if (is_unsigned) {
if (unlikely(Py_SIZE(x) < 0)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to %(type)s");
return (%(type)s)-1;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
if (sizeof(digit) <= sizeof(%(type)s)) { if (sizeof(digit) <= sizeof(%(type)s)) {
switch (Py_SIZE(x)) { switch (Py_SIZE(x)) {
...@@ -1417,6 +1412,11 @@ static CYTHON_INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x ...@@ -1417,6 +1412,11 @@ static CYTHON_INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x
} }
} }
#endif #endif
if (unlikely(Py_SIZE(x) < 0)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to %(type)s");
return (%(type)s)-1;
}
return (%(type)s)PyLong_AsUnsigned%(TypeName)s(x); return (%(type)s)PyLong_AsUnsigned%(TypeName)s(x);
} else { } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
......
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