]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix conversion of double to long; stylistic changes.
authorGuido van Rossum <guido@python.org>
Mon, 3 Jun 1991 10:58:01 +0000 (10:58 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 3 Jun 1991 10:58:01 +0000 (10:58 +0000)
Python/bltinmodule.c

index 9768cd70783a0e166f345cb6588ae118764139ee..47dc9207b57c5c58dd097cba681c4031cf400ac1 100644 (file)
@@ -171,7 +171,6 @@ builtin_float(self, v)
                return newfloatobject((double)x);
        }
        else if (is_longobject(v)) {
-               extern double dgetlongvalue();
                return newfloatobject(dgetlongvalue(v));
        }
        else if (is_floatobject(v)) {
@@ -215,12 +214,13 @@ builtin_int(self, v)
        else if (is_longobject(v)) {
                long x;
                x = getlongvalue(v);
-               if (x == -1 && err_occurred())
+               if (err_occurred())
                        return NULL;
                return newintobject(x);
        }
        else if (is_floatobject(v)) {
                double x = getfloatvalue(v);
+               /* XXX should check for overflow */
                return newintobject((long)x);
        }
        err_setstr(TypeError, "int() argument must be int, long or float");
@@ -269,7 +269,7 @@ builtin_long(self, v)
        }
        else if (is_floatobject(v)) {
                double x = getfloatvalue(v);
-               return newlongobject((long)x);
+               return dnewlongobject(x);
        }
        err_setstr(TypeError, "long() argument must be int, long or float");
        return NULL;