Please ignore my last post. I accidentally pressed send. Here is the
trivial patch.

# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1179004720 -7200
# Node ID a76995d2eede8336dec553f24e1640e92fd77cb1
# Parent  c23d6dc7ac4ba567fda8d7f05cca65f0daabc87a
Fix crash when floor and ceil are applied to a non number.

diff -r c23d6dc7ac4b -r a76995d2eede sage/rings/real_mpfr.pyx
--- a/sage/rings/real_mpfr.pyx  Fri May 11 09:52:14 2007 -0700
+++ b/sage/rings/real_mpfr.pyx  Sat May 12 23:18:40 2007 +0200
@@ -1163,8 +1163,14 @@ cdef class RealNumber(sage.structure.ele
             2
             sage: floor(RR(-5/2))
             -3
-        """
-        cdef RealNumber x
+            sage: floor(RR(+infinity))
+            Traceback (most recent call last):
+            ...
+            ValueError: Calling floor() on infinity or NaN
+        """
+        cdef RealNumber x
+        if not mpfr_number_p(self.value):
+            raise ValueError, 'Calling floor() on infinity or NaN'
         x = self._new()
         mpfr_floor(x.value, self.value)
         return x.integer_part()
@@ -1188,8 +1194,14 @@ cdef class RealNumber(sage.structure.ele
             10000000000000000
             sage: ceil(10^17 * 1.0)
             100000000000000000
-        """
-        cdef RealNumber x
+            sage: ceil(RR(+infinity))
+            Traceback (most recent call last):
+            ...
+            ValueError: Calling ceil() on infinity or NaN
+        """
+        cdef RealNumber x
+        if not mpfr_number_p(self.value):
+            raise ValueError, 'Calling ceil() on infinity or NaN'
         x = self._new()
         mpfr_ceil(x.value, self.value)
         return x.integer_part()




--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to