summaryrefslogtreecommitdiff
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-10-26 01:52:37 +0000
committerRaymond Hettinger <python@rcn.com>2004-10-26 01:52:37 +0000
commit561fbf138d30896af3e7afe33f9bc602dda5f2b7 (patch)
tree58e1d9ea5979c53cb547c7a5fd3b925ef75fb18c /Lib/test/string_tests.py
parent3ed238503d7f9764f670794be20c4a4a0011487a (diff)
downloadcpython-git-561fbf138d30896af3e7afe33f9bc602dda5f2b7.tar.gz
SF bug #1054139: serious string hashing error in 2.4b1
_PyString_Resize() readied strings for mutation but did not invalidate the cached hash value.
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r--Lib/test/string_tests.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 4335965b36..c8ed07cf60 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -80,6 +80,15 @@ class CommonTest(unittest.TestCase):
args = self.fixtype(args)
getattr(object, methodname)(*args)
+ def test_hash(self):
+ # SF bug 1054139: += optimization was not invalidating cached hash value
+ a = self.type2test('DNSSEC')
+ b = self.type2test('')
+ for c in a:
+ b += c
+ hash(b)
+ self.assertEqual(hash(a), hash(b))
+
def test_capitalize(self):
self.checkequal(' hello ', ' hello ', 'capitalize')
self.checkequal('Hello ', 'Hello ','capitalize')