[pypy-commit] pypy py3k: merge default
pjenvey
noreply at buildbot.pypy.org
Wed Jun 19 02:18:54 CEST 2013
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r64935:d854f8325e81
Date: 2013-06-18 17:18 -0700
http://bitbucket.org/pypy/pypy/changeset/d854f8325e81/
Log: merge default
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -1201,8 +1201,7 @@
def _safe_find(self, w_list, obj, start, stop):
l = self.unerase(w_list.lstorage)
for i in range(start, min(stop, len(l))):
- val = l[i]
- if val == obj:
+ if l[i] == obj:
return i
raise ValueError
@@ -1522,6 +1521,18 @@
if reverse:
l.reverse()
+ def _safe_find(self, w_list, obj, start, stop):
+ from rpython.rlib.rfloat import isnan
+ if not isnan(obj):
+ return AbstractUnwrappedStrategy._safe_find(self, w_list, obj,
+ start, stop)
+ # unwrapped nan != nan, finding it requires more effort
+ l = self.unerase(w_list.lstorage)
+ for i in range(start, min(stop, len(l))):
+ if isnan(l[i]):
+ return i
+ raise ValueError
+
class StringListStrategy(AbstractUnwrappedStrategy, ListStrategy):
_none_value = None
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -1268,6 +1268,16 @@
def test_use_method_for_wrong_object(self):
raises(TypeError, list.append, 1, 2)
+ def test_ne_NotImplemented(self):
+ class NonList(object):
+ pass
+ non_list = NonList()
+ assert [] != non_list
+
+ def test_nan_containment(self):
+ nan = float('nan')
+ assert nan in [nan]
+
def test_issue1266(self):
l = list(range(1))
l.pop()
More information about the pypy-commit
mailing list