[Python-checkins] python/dist/src/Lib/test string_tests.py, 1.41, 1.42

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Oct 26 03:52:38 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26552/Lib/test

Modified Files:
	string_tests.py 
Log Message:
SF bug #1054139:  serious string hashing error in 2.4b1

_PyString_Resize() readied strings for mutation but did not invalidate
the cached hash value.



Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- string_tests.py	27 Aug 2004 05:36:07 -0000	1.41
+++ string_tests.py	26 Oct 2004 01:52:36 -0000	1.42
@@ -80,6 +80,15 @@
         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')



More information about the Python-checkins mailing list