[pypy-commit] pypy py3k: Fixed module for py3k.

prestontimmons noreply at buildbot.pypy.org
Wed Mar 14 19:34:35 CET 2012


Author: Preston Timmons <prestontimmons at gmail.com>
Branch: py3k
Changeset: r53565:afba3cd9a570
Date: 2012-03-13 00:48 +0000
http://bitbucket.org/pypy/pypy/changeset/afba3cd9a570/

Log:	Fixed module for py3k.

	The log1p function now raises a ValueError instead of an
	OverflowError when called with -1. Also fixed syntax issues.

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
@@ -380,7 +380,13 @@
 
 def log1p(space, w_x):
     """Find log(x + 1)."""
-    return math1(space, rfloat.log1p, w_x)
+    x = _get_double(space, w_x)
+    try:
+        y = rfloat.log1p(x)
+    except (OverflowError, ValueError):
+        raise OperationError(space.w_ValueError,
+                             space.wrap("math domain error"))
+    return space.wrap(y)
 
 def acosh(space, w_x):
     """Inverse hyperbolic cosine"""
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
@@ -18,7 +18,7 @@
         import math
         for fnname, args, expected in self.cases:
             fn = getattr(math, fnname)
-            print fn, args
+            print(fn, args)
             try:
                 got = fn(*args)
             except ValueError:
@@ -206,8 +206,8 @@
         fail_fmt = "{}:{}({!r}): expected {!r}, got {!r}"
 
         failures = []
-        math_testcases = os.path.join(os.path.dirname(abc.__file__), "test",
-                                      "math_testcases.txt")
+        math_testcases = os.path.join(os.path.dirname(abc.__file__),
+                "../test/math_testcases.txt")
         for id, fn, arg, expected, flags in _parse_mtestfile(math_testcases):
             func = getattr(math, fn)
 


More information about the pypy-commit mailing list