summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2007-06-05 20:22:04 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2007-06-05 20:22:04 (GMT)
commit2a0c081470cc652c35d3bf60f77734d407832136 (patch)
treeafb0545d68679c9c3f96840f8ccbbe2b3142dda8 /Lib/test/test_sys.py
parent360b01a6630e0d129ef0f00ddae1a9d054f9d8d5 (diff)
downloadcpython-2a0c081470cc652c35d3bf60f77734d407832136.zip
cpython-2a0c081470cc652c35d3bf60f77734d407832136.tar.gz
cpython-2a0c081470cc652c35d3bf60f77734d407832136.tar.bz2
Change sys.intern() so that unicode strings can be
interned too. Add a test for this.
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 4118da4..8862661 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -356,7 +356,7 @@ class SysModuleTest(unittest.TestCase):
# We don't want them in the interned dict and if they aren't
# actually interned, we don't want to create the appearance
# that they are by allowing intern() to succeeed.
- class S(str):
+ class S(str8):
def __hash__(self):
return 123
@@ -368,6 +368,17 @@ class SysModuleTest(unittest.TestCase):
setattr(s, s, s)
self.assertEqual(getattr(s, s), s)
+ s = "never interned as unicode before"
+ self.assert_(sys.intern(s) is s)
+ s2 = s.swapcase().swapcase()
+ self.assert_(sys.intern(s2) is s)
+
+ class U(str):
+ def __hash__(self):
+ return 123
+
+ self.assertRaises(TypeError, sys.intern, U("abc"))
+
def test_main():
test.test_support.run_unittest(SysModuleTest)