[pypy-svn] pypy cmath: (lac, arigo)
arigo
commits-noreply at bitbucket.org
Mon Jan 17 19:51:54 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: cmath
Changeset: r40818:e6f1f8134b98
Date: 2011-01-17 19:51 +0100
http://bitbucket.org/pypy/pypy/changeset/e6f1f8134b98/
Log: (lac, arigo)
Missing import and fixes around it.
diff --git a/pypy/module/cmath/test/test_cmath.py b/pypy/module/cmath/test/test_cmath.py
--- a/pypy/module/cmath/test/test_cmath.py
+++ b/pypy/module/cmath/test/test_cmath.py
@@ -66,6 +66,10 @@
phi = cmath.phase(2j)
assert abs(phi - cmath.pi/2) < 1e-10
+ def test_valueerror(self):
+ import cmath
+ raises(ValueError, cmath.log, 0j)
+
def parse_testfile(fname):
"""Parse a file with test values
diff --git a/pypy/module/cmath/interp_cmath.py b/pypy/module/cmath/interp_cmath.py
--- a/pypy/module/cmath/interp_cmath.py
+++ b/pypy/module/cmath/interp_cmath.py
@@ -3,6 +3,7 @@
from pypy.rlib.objectmodel import specialize
from pypy.rlib.rarithmetic import copysign, asinh, log1p, isinf, isnan
from pypy.tool.sourcetools import func_with_new_name
+from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import ObjSpace, W_Root, NoneNotWrapped
from pypy.module.cmath import Module, names_and_docstrings
from pypy.module.cmath.constant import DBL_MIN, CM_SCALE_UP, CM_SCALE_DOWN
@@ -28,7 +29,7 @@
@specialize.arg(0)
-def call_c_func(c_func, x, y):
+def call_c_func(c_func, space, x, y):
try:
result = c_func(x, y)
except ValueError:
@@ -43,7 +44,7 @@
def unaryfn(c_func):
def wrapper(space, w_z):
x, y = space.unpackcomplex(w_z)
- resx, resy = call_c_func(c_func, x, y)
+ resx, resy = call_c_func(c_func, space, x, y)
return space.newcomplex(resx, resy)
#
name = c_func.func_name
@@ -495,7 +496,7 @@
def wrapped_rect(space, w_x, w_y):
x = space.float_w(w_x)
y = space.float_w(w_y)
- resx, resy = call_c_func(c_rect, x, y)
+ resx, resy = call_c_func(c_rect, space, x, y)
return space.newcomplex(resx, resy)
wrapped_rect.unwrap_spec = [ObjSpace, W_Root, W_Root]
wrapped_rect.func_doc = names_and_docstrings['rect']
@@ -527,7 +528,7 @@
def wrapped_phase(space, w_z):
x, y = space.unpackcomplex(w_z)
- result = call_c_func(c_phase, x, y)
+ result = call_c_func(c_phase, space, x, y)
return space.newfloat(result)
wrapped_phase.unwrap_spec = [ObjSpace, W_Root]
wrapped_phase.func_doc = names_and_docstrings['phase']
@@ -559,7 +560,7 @@
def wrapped_polar(space, w_z):
x, y = space.unpackcomplex(w_z)
- resx, resy = call_c_func(c_polar, x, y)
+ resx, resy = call_c_func(c_polar, space, x, y)
return space.newtuple([space.newfloat(resx), space.newfloat(resy)])
wrapped_polar.unwrap_spec = [ObjSpace, W_Root]
wrapped_polar.func_doc = names_and_docstrings['polar']
More information about the Pypy-commit
mailing list