[pypy-svn] r75802 - in pypy/branch/fast-forward/pypy/objspace/std: . test
benjamin at codespeak.net
benjamin at codespeak.net
Sat Jul 3 00:08:00 CEST 2010
Author: benjamin
Date: Sat Jul 3 00:07:58 2010
New Revision: 75802
Modified:
pypy/branch/fast-forward/pypy/objspace/std/floatobject.py
pypy/branch/fast-forward/pypy/objspace/std/test/test_floatobject.py
Log:
pow(0.0, -inf) is infinity
Modified: pypy/branch/fast-forward/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/floatobject.py (original)
+++ pypy/branch/fast-forward/pypy/objspace/std/floatobject.py Sat Jul 3 00:07:58 2010
@@ -433,9 +433,13 @@
return space.wrap(1.0)
else:
return space.wrap( -1.0)
- elif x == 0.0 and y < 0.0:
- raise OperationError(space.w_ZeroDivisionError,
- space.wrap("0.0 cannot be raised to a negative power"))
+ elif x == 0.0:
+ if y < 0.0:
+ if isinf(y):
+ return space.wrap(float("inf"))
+ raise OperationError(space.w_ZeroDivisionError,
+ space.wrap("0.0 cannot be raised to "
+ "a negative power"))
raise OperationError(space.w_ValueError,
space.wrap("float power"))
return W_FloatObject(z)
Modified: pypy/branch/fast-forward/pypy/objspace/std/test/test_floatobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/test/test_floatobject.py (original)
+++ pypy/branch/fast-forward/pypy/objspace/std/test/test_floatobject.py Sat Jul 3 00:07:58 2010
@@ -158,6 +158,7 @@
assert pw(-1.0, 2.0) == 1.0
assert pw(-1.0, 3.0) == -1.0
assert pw(-1.0, 1e200) == 1.0
+ assert pw(0.0, float("-inf")) == float("inf")
def test_pow_neg_base(self):
def pw(x, y):
More information about the Pypy-commit
mailing list