[Python-checkins] r60832 - in python/branches/trunk-math: Doc/library/stdtypes.rst Lib/test/test_builtin.py Lib/test/test_float.py Misc/NEWS Objects/floatobject.c
M.-A. Lemburg
mal at egenix.com
Fri Feb 15 11:42:03 CET 2008
On 2008-02-15 11:38, christian.heimes wrote:
> Author: christian.heimes
> Date: Fri Feb 15 11:38:35 2008
> New Revision: 60832
>
> Modified:
> python/branches/trunk-math/Doc/library/stdtypes.rst
> python/branches/trunk-math/Lib/test/test_builtin.py
> python/branches/trunk-math/Lib/test/test_float.py
> python/branches/trunk-math/Misc/NEWS
> python/branches/trunk-math/Objects/floatobject.c
> Log:
> Added methods is_inf, is_nan and is_integer to float type
>
> Modified: python/branches/trunk-math/Objects/floatobject.c
> ==============================================================================
> --- python/branches/trunk-math/Objects/floatobject.c (original)
> +++ python/branches/trunk-math/Objects/floatobject.c Fri Feb 15 11:38:35 2008
> @@ -1131,6 +1131,46 @@
> }
>
> static PyObject *
> +float_is_integer(PyObject *v)
> +{
> + double x = PyFloat_AsDouble(v);
> + PyObject *o;
> +
> + if (x == -1.0 && PyErr_Occurred())
> + return NULL;
> + if (!Py_IS_FINITE(x))
> + Py_RETURN_FALSE;
> + PyFPE_START_PROTECT("is_integer", return 0)
Shouldn't this be return NULL ?
> + o = (floor(x) == x) ? Py_True : Py_False;
> + PyFPE_END_PROTECT(x)
> + if (errno != 0) {
> + PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError :
> + PyExc_ValueError);
> + return NULL;
> + }
> + Py_INCREF(o);
> + return o;
> +}
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Feb 15 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-checkins
mailing list