[pypy-svn] r15916 - in pypy/dist/pypy: annotation objspace/flow objspace/std

pedronis at codespeak.net pedronis at codespeak.net
Wed Aug 10 16:19:07 CEST 2005


Author: pedronis
Date: Wed Aug 10 16:19:04 2005
New Revision: 15916

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/objspace/flow/objspace.py
   pypy/dist/pypy/objspace/std/floatobject.py
Log:
- removing the only place that would have needed float_div_zer

- pow with floats can result in an overflow error because internally is like math.pow



Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Wed Aug 10 16:19:04 2005
@@ -331,6 +331,7 @@
 
     def pow((flt1, flt2), obj3):
         return SomeFloat()
+    pow.can_only_throw = [ZeroDivisionError, ValueError, OverflowError]    
 
 
 class __extend__(pairtype(SomeList, SomeList)):

Modified: pypy/dist/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/objspace.py	(original)
+++ pypy/dist/pypy/objspace/flow/objspace.py	Wed Aug 10 16:19:04 2005
@@ -476,6 +476,8 @@
                    inplace_lshift""", OverflowError) # without a _ovf version
 _add_except_ovf("""neg abs add sub mul
                    floordiv div mod pow lshift""")   # with a _ovf version
+_add_exceptions("""pow""",
+                OverflowError) # for the float case
 del _add_exceptions, _add_except_ovf
 
 def extract_cell_content(c):

Modified: pypy/dist/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/floatobject.py	(original)
+++ pypy/dist/pypy/objspace/std/floatobject.py	Wed Aug 10 16:19:04 2005
@@ -193,10 +193,10 @@
 def div__Float_Float(space, w_float1, w_float2):
     x = w_float1.floatval
     y = w_float2.floatval
+    if y == 0.0:
+        raise FailedToImplement(space.w_ZeroDivisionError, space.wrap("float division"))    
     try:
         z = x / y
-    except ZeroDivisionError:
-        raise OperationError(space.w_ZeroDivisionError, space.wrap("float division"))
     except FloatingPointError:
         raise FailedToImplement(space.w_FloatingPointError, space.wrap("float division"))
     # no overflow
@@ -219,7 +219,6 @@
     if y == 0.0:
         raise FailedToImplement(space.w_ZeroDivisionError, space.wrap("float modulo"))
     try:
-        # this is a hack!!!! must be replaced by a real fmod function
         mod = math.fmod(x, y)
         if (mod and ((y < 0.0) != (mod < 0.0))):
             mod += y
@@ -234,7 +233,6 @@
     if y == 0.0:
         raise FailedToImplement(space.w_ZeroDivisionError, space.wrap("float modulo"))
     try:
-        # XXX this is a hack!!!! must be replaced by a real fmod function
         mod = math.fmod(x, y)
         # fmod is typically exact, so vx-mod is *mathematically* an
         # exact multiple of wx.  But this is fp arithmetic, and fp



More information about the Pypy-commit mailing list