summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-12 07:54:51 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-12 07:54:51 (GMT)
commit111f60964ee438e64d82cb884f9dfdec10321b7c (patch)
tree18d0b7bf790ec9fc702aa3e5e95290e2ae0c046f /Lib/test/test_descr.py
parentaf90b3e610212a4994962246875e5bfc5574dff6 (diff)
downloadcpython-111f60964ee438e64d82cb884f9dfdec10321b7c.zip
cpython-111f60964ee438e64d82cb884f9dfdec10321b7c.tar.gz
cpython-111f60964ee438e64d82cb884f9dfdec10321b7c.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 8d9e81e..b029979 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1529,6 +1529,20 @@ def inherits():
verify(s.lower().__class__ is str)
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
def rev(self):