Author: Armin Rigo <[email protected]>
Branch:
Changeset: r75811:68255911a884
Date: 2015-02-10 19:34 +0100
http://bitbucket.org/pypy/pypy/changeset/68255911a884/
Log: Same issue with tuples containing NaNs
diff --git a/pypy/objspace/std/specialisedtupleobject.py
b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -5,6 +5,7 @@
from rpython.rlib.rarithmetic import intmask
from rpython.rlib.unroll import unrolling_iterable
from rpython.tool.sourcetools import func_with_new_name
+from rpython.rlib.longlong2float import float2longlong
class NotSpecialised(Exception):
@@ -97,6 +98,11 @@
return space.w_False
else:
if myval != otherval:
+ if typetuple[i] == float:
+ # issue with NaNs, which should be equal here
+ if (float2longlong(myval) ==
+ float2longlong(otherval)):
+ continue
return space.w_False
return space.w_True
diff --git a/pypy/objspace/std/test/test_specialisedtupleobject.py
b/pypy/objspace/std/test/test_specialisedtupleobject.py
--- a/pypy/objspace/std/test/test_specialisedtupleobject.py
+++ b/pypy/objspace/std/test/test_specialisedtupleobject.py
@@ -222,6 +222,13 @@
t = (F(42), F(43))
assert type(t[0]) is F
+ def test_bug_tuples_of_nans(self):
+ N = float('nan')
+ T = (N, N)
+ assert N in T
+ assert T == (N, N)
+ assert (0.0, 0.0) == (-0.0, -0.0)
+
class AppTestAll(test_tupleobject.AppTestW_TupleObject):
spaceconfig = {"objspace.std.withspecialisedtuple": True}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit