]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 3118: make test_math pass on Ubuntu/ia64. exp(-745.0) was raising
authorMark Dickinson <dickinsm@gmail.com>
Tue, 17 Jun 2008 21:16:55 +0000 (21:16 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Tue, 17 Jun 2008 21:16:55 +0000 (21:16 +0000)
OverflowError incorrectly on this platform, presumably as a result of
the libm setting errno = ERANGE for this call.

Modules/mathmodule.c

index 32c2400f4cc8eb8eb9d3059e3443f1764303839c..1066702f1a9e5ebf5cdf833ee0d8b1aa60dc6b53 100644 (file)
@@ -82,12 +82,17 @@ is_error(double x)
                 * should return a zero on underflow, and +- HUGE_VAL on
                 * overflow, so testing the result for zero suffices to
                 * distinguish the cases).
+                *
+                * On some platforms (Ubuntu/ia64) it seems that errno can be
+                * set to ERANGE for subnormal results that do *not* underflow
+                * to zero.  So to be safe, we'll ignore ERANGE whenever the
+                * function result is less than one in absolute value.
                 */
-               if (x)
+               if (fabs(x) < 1.0)
+                       result = 0;
+               else
                        PyErr_SetString(PyExc_OverflowError,
                                        "math range error");
-               else
-                       result = 0;
        }
        else
                 /* Unexpected math error */