Author: Tyler Wade <[email protected]>
Branch: utf8-unicode2
Changeset: r72727:c80352ad6379
Date: 2014-08-09 02:42 -0500
http://bitbucket.org/pypy/pypy/changeset/c80352ad6379/
Log: Fix the unicode strategy of list.find
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
@@ -1718,6 +1718,14 @@
def list_is_correct_type(self, w_list):
return w_list.strategy is self.space.fromcache(UnicodeListStrategy)
+ 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 utf8.EQ(val, obj):
+ return i
+ raise ValueError
+
def sort(self, w_list, reverse):
l = self.unerase(w_list.lstorage)
sorter = UnicodeSort(l, len(l))
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
@@ -973,6 +973,10 @@
assert c.index(0) == 0.0
raises(ValueError, c.index, 3)
+ c = [u'1', u'2']
+ assert c.index(u'2') == 1
+ raises(ValueError, c.index, u'3')
+
def test_index_cpython_bug(self):
if self.on_cpython:
skip("cpython has a bug here")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit