Commit da0c047c authored by Stefan Behnel's avatar Stefan Behnel

add safety guard for ill defined user types

parent b525cf34
......@@ -1410,18 +1410,22 @@ static CYTHON_INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x
return (%(type)s)-1;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
switch (Py_SIZE(x)) {
case 0: return 0;
case 1: return (%(type)s) ((PyLongObject*)x)->ob_digit[0];
if (sizeof(digit) <= sizeof(%(type)s)) {
switch (Py_SIZE(x)) {
case 0: return 0;
case 1: return (%(type)s) ((PyLongObject*)x)->ob_digit[0];
}
}
#endif
return (%(type)s)PyLong_AsUnsigned%(TypeName)s(x);
} else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
switch (Py_SIZE(x)) {
case 0: return 0;
case 1: return +(%(type)s) ((PyLongObject*)x)->ob_digit[0];
case -1: return -(%(type)s) ((PyLongObject*)x)->ob_digit[0];
if (sizeof(digit) <= sizeof(%(type)s)) {
switch (Py_SIZE(x)) {
case 0: return 0;
case 1: return +(%(type)s) ((PyLongObject*)x)->ob_digit[0];
case -1: return -(%(type)s) ((PyLongObject*)x)->ob_digit[0];
}
}
#endif
return (%(type)s)PyLong_As%(TypeName)s(x);
......
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