Author: Antonio Cuni <[email protected]>
Branch: unicode-strategies
Changeset: r58471:36ecc34cfb00
Date: 2012-10-26 19:18 +0200
http://bitbucket.org/pypy/pypy/changeset/36ecc34cfb00/
Log: unicode.join uses listview_unicode
diff --git a/pypy/objspace/std/test/test_liststrategies.py
b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -527,6 +527,12 @@
w_l.getitems = None
assert space.str_w(space.call_method(space.wrap("c"), "join", w_l)) ==
"acb"
+ def test_unicode_join_uses_listview_unicode(self):
+ space = self.space
+ w_l = self.space.newlist([self.space.wrap(u'a'),
self.space.wrap(u'b')])
+ w_l.getitems = None
+ assert space.unicode_w(space.call_method(space.wrap(u"c"), "join",
w_l)) == u"acb"
+
def test_string_join_returns_same_instance(self):
space = self.space
w_text = space.wrap("text")
diff --git a/pypy/objspace/std/unicodeobject.py
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -202,6 +202,11 @@
return space.newbool(container.find(item) != -1)
def unicode_join__Unicode_ANY(space, w_self, w_list):
+ l = space.listview_unicode(w_list)
+ if l is not None:
+ if len(l) == 1:
+ return space.wrap(l[0])
+ return space.wrap(w_self._value.join(l))
list_w = space.listview(w_list)
size = len(list_w)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit