Mailing List Archive

CVS: python/dist/src/Lib/test test_descr.py,1.44,1.45
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv24631/python/Lib/test

Modified Files:
test_descr.py
Log Message:
More bug 460020: lots of string optimizations inhibited for string
subclasses, all "the usual" ones (slicing etc), plus replace, translate,
ljust, rjust, center and strip. I don't know how to be sure they've all
been caught.

Question: Should we complain if someone tries to intern an instance of
a string subclass? I hate to slow any code on those paths.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** test_descr.py 2001/09/11 22:31:33 1.44
--- test_descr.py 2001/09/12 02:18:30 1.45
***************
*** 1482,1488 ****
verify(str(s).__class__ is str)

! s = madstring("\x00" * 5)
! verify(str(s) == "\x00" * 5)
verify(str(s).__class__ is str)

class madunicode(unicode):
--- 1482,1511 ----
verify(str(s).__class__ is str)

! base = "\x00" * 5
! s = madstring(base)
! verify(str(s) == base)
verify(str(s).__class__ is str)
+ verify((s + "").__class__ is str)
+ verify(("" + s).__class__ is str)
+ verify((s * 0).__class__ is str)
+ verify((s * 1).__class__ is str)
+ verify((s * 2).__class__ is str)
+ verify(s[:].__class__ is str)
+ verify(s[0:0].__class__ is str)
+ verify(s.strip().__class__ is str)
+ identitytab = ''.join([chr(i) for i in range(256)])
+ verify(s.translate(identitytab).__class__ is str)
+ verify(s.translate(identitytab) == base)
+ verify(s.translate(identitytab, "x").__class__ is str)
+ verify(s.translate(identitytab, "x") == base)
+ verify(s.translate(identitytab, "\x00") == "")
+ verify(s.replace("x", "x").__class__ is str)
+ verify(s.replace("x", "x") == base)
+ verify(s.ljust(len(s)).__class__ is str)
+ verify(s.ljust(len(s)) == base)
+ verify(s.rjust(len(s)).__class__ is str)
+ verify(s.rjust(len(s)) == base)
+ verify(s.center(len(s)).__class__ is str)
+ verify(s.center(len(s)) == base)

class madunicode(unicode):