[pypy-commit] pypy default: handle special values
gutworth
noreply at buildbot.pypy.org
Sat Oct 29 01:37:57 CEST 2011
Author: Benjamin Peterson <benjamin at python.org>
Branch:
Changeset: r48595:7cfece2a13d1
Date: 2011-10-28 19:37 -0400
http://bitbucket.org/pypy/pypy/changeset/7cfece2a13d1/
Log: handle special values
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -547,7 +547,10 @@
return space.newtuple([space.int(w_num), space.int(w_den)])
def float_is_integer__Float(space, w_float):
- return space.wrap(math.floor(w_float.floatval) == w_float.floatval)
+ v = w_float.floatval
+ if not rfloat.isfinite(v):
+ return space.w_False
+ return space.wrap(math.floor(v) == v)
from pypy.objspace.std import floattype
register_all(vars(), floattype)
diff --git a/pypy/objspace/std/test/test_floatobject.py b/pypy/objspace/std/test/test_floatobject.py
--- a/pypy/objspace/std/test/test_floatobject.py
+++ b/pypy/objspace/std/test/test_floatobject.py
@@ -66,6 +66,8 @@
def test_isinteger(self):
assert (1.).is_integer()
assert not (1.1).is_integer()
+ assert not float("inf").is_integer()
+ assert not float("nan").is_integer()
def test_conjugate(self):
assert (1.).conjugate() == 1.
More information about the pypy-commit
mailing list