Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65721:350779843103
Date: 2013-07-27 19:58 +0200
http://bitbucket.org/pypy/pypy/changeset/350779843103/
Log: Test and fix for u''.join([<unicode subclass instance>]).
diff --git a/pypy/objspace/std/test/test_unicodeobject.py
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -905,3 +905,14 @@
res = 'one!two!three!'.replace(u'!', u'@', 1)
assert res == u'one@two!three!'
assert type(res) == unicode
+
+ def test_join_subclass(self):
+ class UnicodeSubclass(unicode):
+ pass
+ class StrSubclass(str):
+ pass
+
+ s1 = UnicodeSubclass(u'a')
+ assert u''.join([s1]) is not s1
+ s2 = StrSubclass(u'a')
+ assert u''.join([s2]) is not s2
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
@@ -196,8 +196,8 @@
return space.is_w(space.type(w_obj), space.w_unicode)
def _join_check_item(self, space, w_obj):
- if (space.is_w(space.type(w_obj), space.w_str) or
- space.is_w(space.type(w_obj), space.w_unicode)):
+ if (space.isinstance_w(w_obj, space.w_str) or
+ space.isinstance_w(w_obj, space.w_unicode)):
return 0
return 1
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit