]> granicus.if.org Git - python/commitdiff
Issue #2801: fix bug in float.is_integer where ValueError
authorMark Dickinson <dickinsm@gmail.com>
Fri, 9 May 2008 16:14:15 +0000 (16:14 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Fri, 9 May 2008 16:14:15 +0000 (16:14 +0000)
could be incorrectly raised.  This is a backport of the
Py3k fix in r62939.  (Should really have been fixed
in the trunk first and svnmerged into py3k.)

Misc/NEWS
Objects/floatobject.c

index 58fd955bf5190ad6afc6f3c2d5c0aba788166907..12522dbfe680358ccfde00fd917418e4b0b88316 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.6 beta 1?
 Core and Builtins
 -----------------
 
+- Issue #2801: fix bug in the float.is_integer method where a ValueError
+  was sometimes incorrectly raised.
+
 - Issue #2790: sys.flags was not properly exposing its bytes_warning attribute.
 
 Extension Modules
index f79995cb3f239872171776a897b13d8f52287d64..ceb0b6dfb86f92f4b91bfea710aea105a3bd8796 100644 (file)
@@ -1031,6 +1031,7 @@ float_is_integer(PyObject *v)
                return NULL;
        if (!Py_IS_FINITE(x))
                Py_RETURN_FALSE;
+       errno = 0;
        PyFPE_START_PROTECT("is_integer", return NULL)
        o = (floor(x) == x) ? Py_True : Py_False;
        PyFPE_END_PROTECT(x)