Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r59427:293521d40d29
Date: 2012-12-14 17:19 -0800
http://bitbucket.org/pypy/pypy/changeset/293521d40d29/

Log:    adapt to ll_math now matching 2.x's log1p OverflowError case

diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py
--- a/pypy/module/math/interp_math.py
+++ b/pypy/module/math/interp_math.py
@@ -394,8 +394,8 @@
     try:
         return math1(space, rfloat.log1p, w_x)
     except OperationError as e:
-        # Python 2.x raises a OverflowError improperly.
-        if we_are_translated() or not e.match(space, space.w_OverflowError):
+        # Python 2.x (and thus ll_math) raises a OverflowError improperly.
+        if not e.match(space, space.w_OverflowError):
             raise
         raise OperationError(space.w_ValueError, space.wrap("math domain 
error"))
 
diff --git a/pypy/module/math/test/test_direct.py 
b/pypy/module/math/test/test_direct.py
--- a/pypy/module/math/test/test_direct.py
+++ b/pypy/module/math/test/test_direct.py
@@ -73,7 +73,11 @@
         ('pow', (10.0, 40000.0), OverflowError),
         ('ldexp', (10.0, 40000), OverflowError),
         ('log', (0.0,), ValueError), #cpython does it this way
+
+        # an OverflowError to match 2.x/ll_math, but test_math switches
+        # this to ValueError to match 3.x
         ('log1p', (-1.0,), OverflowError),
+
         ('log', (-1.,), ValueError),
         ('log10', (0.0,), ValueError), #cpython does it this way
         ]
diff --git a/pypy/module/math/test/test_math.py 
b/pypy/module/math/test/test_math.py
--- a/pypy/module/math/test/test_math.py
+++ b/pypy/module/math/test/test_math.py
@@ -14,6 +14,11 @@
         space = cls.space
         cases = []
         for a, b, expected in test_direct.MathTests.TESTCASES:
+            # marked as OverflowError to match 2.x/ll_math in
+            # test_direct, but this is a ValueError on 3.x
+            if (a, b, expected) == ('log1p', (-1.0,), OverflowError):
+                expected = ValueError
+
             if type(expected) is type and issubclass(expected, Exception):
                 expected = getattr(space, "w_%s" % expected.__name__)
             elif callable(expected):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to