]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Reverting the patch that tried to fix the issue whereby x**2 raises
authorAlex Martelli <aleaxit@gmail.com>
Wed, 23 Aug 2006 22:17:59 +0000 (22:17 +0000)
committerAlex Martelli <aleaxit@gmail.com>
Wed, 23 Aug 2006 22:17:59 +0000 (22:17 +0000)
OverflowError while x*x succeeds and produces infinity; apparently
these inconsistencies cannot be fixed across ``all'' platforms and
there's a widespread feeling that therefore ``every'' platform
should keep suffering forevermore.  Ah well.

Lib/test/test_float.py
Objects/floatobject.c

index d616ad9543dc7ad71f3ef324834d010b396e2b92..fb47db8eb087adb749e3176b89cda197cf437325 100644 (file)
@@ -99,25 +99,12 @@ class IEEEFormatTestCase(unittest.TestCase):
                               ('<f', LE_FLOAT_NAN)]:
                 struct.unpack(fmt, data)
 
-# on an IEEE platform, "overflowing" operations produce infinity
-
-class IEEEOperationsTestCase(unittest.TestCase):
-    if float.__getformat__("double").startswith("IEEE"):
-        def test_double_infinity(self):
-            big = 4.8e159
-            pro = big*big
-            self.assertEquals(repr(pro), 'inf')
-            sqr = big**2
-            self.assertEquals(repr(sqr), 'inf')
-
 
 def test_main():
     test_support.run_unittest(
         FormatFunctionsTestCase,
         UnknownFormatTestCase,
-        IEEEFormatTestCase,
-        IEEEOperationsTestCase,
-        )
+        IEEEFormatTestCase)
 
 if __name__ == '__main__':
     test_main()
index 5aeabd9d93fa9cdec81253eeac711338186bcd37..fa090846692867ff442a2b52f9899fe55617fab2 100644 (file)
@@ -821,12 +821,12 @@ float_pow(PyObject *v, PyObject *w, PyObject *z)
        ix = pow(iv, iw);
        PyFPE_END_PROTECT(ix)
        Py_ADJUST_ERANGE1(ix);
-        /* we need to ignore ERANGE here and just return inf */
-       if (errno != 0 && errno != ERANGE) {
+       if (errno != 0) {
                /* We don't expect any errno value other than ERANGE, but
                 * the range of libm bugs appears unbounded.
                 */
-               PyErr_SetFromErrno(PyExc_ValueError);
+               PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError :
+                                                    PyExc_ValueError);
                return NULL;
        }
        return PyFloat_FromDouble(ix);