]> granicus.if.org Git - python/commitdiff
Patch by Tim Peters fixing PR#89:
authorGuido van Rossum <guido@python.org>
Mon, 27 Sep 1999 17:11:52 +0000 (17:11 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 27 Sep 1999 17:11:52 +0000 (17:11 +0000)
long(+/- infinity) returns nonsense.

Objects/longobject.c

index 7c805a5259f6d817ce251a56dd90bc4ec30abeb8..9f605a1470ea59c4993ee6c383e9e93247b27020 100644 (file)
@@ -145,6 +145,11 @@ PyLong_FromDouble(dval)
        double frac;
        int i, ndig, expo, neg;
        neg = 0;
+       if (dval && dval * 0.5 == dval) {
+               PyErr_SetString(PyExc_OverflowError,
+                       "cannot convert float infinity to long");
+               return NULL;
+       }
        if (dval < 0.0) {
                neg = 1;
                dval = -dval;