Commit 5ef8c817 authored by Robert Bradshaw's avatar Robert Bradshaw

imported patch shrink-int-convert

parent 021488a5
...@@ -599,15 +599,12 @@ static INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x) { ...@@ -599,15 +599,12 @@ static INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x) {
if (sizeof(%(type)s) < sizeof(long)) { if (sizeof(%(type)s) < sizeof(long)) {
long val = __Pyx_PyInt_AsLong(x); long val = __Pyx_PyInt_AsLong(x);
if (unlikely(val != (long)(%(type)s)val)) { if (unlikely(val != (long)(%(type)s)val)) {
if (unlikely(val == -1 && PyErr_Occurred())) if (!unlikely(val == -1 && PyErr_Occurred())) {
return (%(type)s)-1;
if (((%(type)s)-1) > ((%(type)s)0) && unlikely(val < 0)) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to %(type)s"); (((%(type)s)-1) > ((%(type)s)0) && unlikely(val < 0)) ?
return (%(type)s)-1; "can't convert negative value to %(type)s" :
"value too large to convert to %(type)s");
} }
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to %(type)s");
return (%(type)s)-1; return (%(type)s)-1;
} }
return (%(type)s)val; return (%(type)s)val;
......
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