More on bug 460020: disable many optimizations of unicode subclasses.
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index a29eb23..b791037 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1486,13 +1486,25 @@
verify(str(s) == base)
verify(str(s).__class__ is str)
verify((s + "").__class__ is str)
+ verify(s + "" == base)
verify(("" + s).__class__ is str)
+ verify("" + s == base)
verify((s * 0).__class__ is str)
+ verify(s * 0 == "")
verify((s * 1).__class__ is str)
+ verify(s * 1 == base)
verify((s * 2).__class__ is str)
+ verify(s * 2 == base + base)
verify(s[:].__class__ is str)
+ verify(s[:] == base)
verify(s[0:0].__class__ is str)
+ verify(s[0:0] == "")
verify(s.strip().__class__ is str)
+ verify(s.strip() == base)
+ verify(s.lstrip().__class__ is str)
+ verify(s.lstrip() == base)
+ verify(s.rstrip().__class__ is str)
+ verify(s.rstrip() == base)
identitytab = ''.join([chr(i) for i in range(256)])
verify(s.translate(identitytab).__class__ is str)
verify(s.translate(identitytab) == base)
@@ -1507,6 +1519,8 @@
verify(s.rjust(len(s)) == base)
verify(s.center(len(s)).__class__ is str)
verify(s.center(len(s)) == base)
+ verify(s.lower().__class__ is str)
+ verify(s.lower() == base)
class madunicode(unicode):
_rev = None
@@ -1520,9 +1534,48 @@
u = madunicode("ABCDEF")
verify(u.rev() == madunicode(u"FEDCBA"))
verify(u.rev().rev() == madunicode(u"ABCDEF"))
- u = madunicode(u"12345")
- verify(unicode(u) == u"12345")
+ base = u"12345"
+ u = madunicode(base)
+ verify(unicode(u) == base)
verify(unicode(u).__class__ is unicode)
+ verify(u.strip().__class__ is unicode)
+ verify(u.strip() == base)
+ verify(u.lstrip().__class__ is unicode)
+ verify(u.lstrip() == base)
+ verify(u.rstrip().__class__ is unicode)
+ verify(u.rstrip() == base)
+ verify(u.replace(u"x", u"x").__class__ is unicode)
+ verify(u.replace(u"x", u"x") == base)
+ verify(u.replace(u"xy", u"xy").__class__ is unicode)
+ verify(u.replace(u"xy", u"xy") == base)
+ verify(u.center(len(u)).__class__ is unicode)
+ verify(u.center(len(u)) == base)
+ verify(u.ljust(len(u)).__class__ is unicode)
+ verify(u.ljust(len(u)) == base)
+ verify(u.rjust(len(u)).__class__ is unicode)
+ verify(u.rjust(len(u)) == base)
+ verify(u.lower().__class__ is unicode)
+ verify(u.lower() == base)
+ verify(u.upper().__class__ is unicode)
+ verify(u.upper() == base)
+ verify(u.capitalize().__class__ is unicode)
+ verify(u.capitalize() == base)
+ verify(u.title().__class__ is unicode)
+ verify(u.title() == base)
+ verify((u + u"").__class__ is unicode)
+ verify(u + u"" == base)
+ verify((u"" + u).__class__ is unicode)
+ verify(u"" + u == base)
+ verify((u * 0).__class__ is unicode)
+ verify(u * 0 == u"")
+ verify((u * 1).__class__ is unicode)
+ verify(u * 1 == base)
+ verify((u * 2).__class__ is unicode)
+ verify(u * 2 == base + base)
+ verify(u[:].__class__ is unicode)
+ verify(u[:] == base)
+ verify(u[0:0].__class__ is unicode)
+ verify(u[0:0] == u"")
def all():
lists()