diff -r fc5d2f4291ac Python/getargs.c --- a/Python/getargs.c Fri May 04 02:31:57 2012 -0700 +++ b/Python/getargs.c Fri May 04 17:34:27 2012 +0300 @@ -4,6 +4,7 @@ #include "Python.h" #include +#include #ifdef __cplusplus @@ -757,8 +758,19 @@ double dval = PyFloat_AsDouble(arg); if (PyErr_Occurred()) RETURN_ERR_OCCURRED; - else - *p = (float) dval; + if (Py_IS_FINITE(dval)) { + if (dval < -FLT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "float is less than minimum"); + RETURN_ERR_OCCURRED; + } + else if (dval > FLT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "float is greater than maximum"); + RETURN_ERR_OCCURRED; + } + } + *p = (float) dval; break; }