[pypy-commit] pypy default: float('-nan') should really return -NAN.

arigo noreply at buildbot.pypy.org
Tue Mar 13 21:20:32 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r53475:bdd282c7220f
Date: 2012-03-13 13:20 -0700
http://bitbucket.org/pypy/pypy/changeset/bdd282c7220f/

Log:	float('-nan') should really return -NAN.

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
@@ -1,3 +1,4 @@
+from __future__ import with_statement
 import sys
 from pypy.conftest import gettestobjspace
 from pypy.module.math.test import test_direct
@@ -268,3 +269,7 @@
             def __trunc__(self):
                 return "truncated"
         assert math.trunc(foo()) == "truncated"
+
+    def test_copysign_nan(self):
+        import math
+        assert math.copysign(1.0, float('-nan')) == -1.0
diff --git a/pypy/objspace/std/strutil.py b/pypy/objspace/std/strutil.py
--- a/pypy/objspace/std/strutil.py
+++ b/pypy/objspace/std/strutil.py
@@ -177,8 +177,10 @@
         return INFINITY
     elif low == "infinity" or low == "+infinity":
         return INFINITY
-    elif low == "nan" or low == "-nan" or low == "+nan":
+    elif low == "nan" or low == "+nan":
         return NAN
+    elif low == "-nan":
+        return -NAN
 
     try:
         return rstring_to_float(s)


More information about the pypy-commit mailing list