]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make math.{floor,ceil}({int,long}) return float again for backwards
authorJeffrey Yasskin <jyasskin@gmail.com>
Fri, 4 Jan 2008 08:01:23 +0000 (08:01 +0000)
committerJeffrey Yasskin <jyasskin@gmail.com>
Fri, 4 Jan 2008 08:01:23 +0000 (08:01 +0000)
compatibility after r59671 made them return integral types.

Lib/test/test_math.py
Objects/intobject.c
Objects/longobject.c

index f5bf1a3f98355116339e975fd57f74ab08df7c60..5313c3cad03e7d31c2a104e0bce2d5b8ddd63320 100644 (file)
@@ -51,6 +51,10 @@ class MathTests(unittest.TestCase):
 
     def testCeil(self):
         self.assertRaises(TypeError, math.ceil)
+        # These types will be int in py3k.
+        self.assertEquals(float, type(math.ceil(1)))
+        self.assertEquals(float, type(math.ceil(1L)))
+        self.assertEquals(float, type(math.ceil(1.0)))
         self.ftest('ceil(0.5)', math.ceil(0.5), 1)
         self.ftest('ceil(1.0)', math.ceil(1.0), 1)
         self.ftest('ceil(1.5)', math.ceil(1.5), 2)
@@ -103,6 +107,10 @@ class MathTests(unittest.TestCase):
 
     def testFloor(self):
         self.assertRaises(TypeError, math.floor)
+        # These types will be int in py3k.
+        self.assertEquals(float, type(math.floor(1)))
+        self.assertEquals(float, type(math.floor(1L)))
+        self.assertEquals(float, type(math.floor(1.0)))
         self.ftest('floor(0.5)', math.floor(0.5), 0)
         self.ftest('floor(1.0)', math.floor(1.0), 1)
         self.ftest('floor(1.5)', math.floor(1.5), 1)
index a93b9b201a43559ac54f2e86a1c2ff6e24833256..96d7f76ab1ca8abb14ad013ca6004fada4b4688f 100644 (file)
@@ -1086,9 +1086,9 @@ static PyMethodDef int_methods[] = {
         "Returns self, the complex conjugate of any int."},
        {"__trunc__",   (PyCFunction)int_int,   METH_NOARGS,
          "Truncating an Integral returns itself."},
-       {"__floor__",   (PyCFunction)int_int,   METH_NOARGS,
+       {"__floor__",   (PyCFunction)int_float, METH_NOARGS,
          "Flooring an Integral returns itself."},
-       {"__ceil__",    (PyCFunction)int_int,   METH_NOARGS,
+       {"__ceil__",    (PyCFunction)int_float, METH_NOARGS,
          "Ceiling of an Integral returns itself."},
        {"__round__",   (PyCFunction)int_round, METH_VARARGS,
          "Rounding an Integral returns itself.\n"
index e2ffb35a9747fbaad81ef9cca519ebcf1f86ce41..eea5c3bad50f634d1610676eb19fdffdf2bf414a 100644 (file)
@@ -3402,9 +3402,9 @@ static PyMethodDef long_methods[] = {
         "Returns self, the complex conjugate of any long."},
        {"__trunc__",   (PyCFunction)long_long, METH_NOARGS,
          "Truncating an Integral returns itself."},
-       {"__floor__",   (PyCFunction)long_long, METH_NOARGS,
+       {"__floor__",   (PyCFunction)long_float, METH_NOARGS,
          "Flooring an Integral returns itself."},
-       {"__ceil__",    (PyCFunction)long_long, METH_NOARGS,
+       {"__ceil__",    (PyCFunction)long_float, METH_NOARGS,
          "Ceiling of an Integral returns itself."},
        {"__round__",   (PyCFunction)long_round, METH_VARARGS,
          "Rounding an Integral returns itself.\n"