[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.47,1.48

Tim Peters tim_one@users.sourceforge.net
Wed, 12 Sep 2001 00:54:53 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv18582/python/dist/src/Lib/test

Modified Files:
	test_descr.py 
Log Message:
If interning an instance of a string subclass, intern a real string object
with the same value instead.  This ensures that a string (or string
subclass) object's ob_sinterned pointer is always a str (or NULL), and
that the dict of interned strings only has strs as keys.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** test_descr.py	2001/09/12 05:18:58	1.47
--- test_descr.py	2001/09/12 07:54:51	1.48
***************
*** 1530,1533 ****
--- 1530,1547 ----
      verify(s.lower() == base)
  
+     s = madstring("x y")
+     verify(intern(s).__class__ is str)
+     verify(intern(s) is intern("x y"))
+     verify(intern(s) == "x y")
+ 
+     i = intern("y x")
+     s = madstring("y x")
+     verify(intern(s).__class__ is str)
+     verify(intern(s) is i)
+ 
+     s = madstring(i)
+     verify(intern(s).__class__ is str)
+     verify(intern(s) is i)
+ 
      class madunicode(unicode):
          _rev = None