diff Lib/UserString.py @ 47961:f9b80a820a25 legacy-trunk

Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful
author Nick Coghlan <ncoghlan@gmail.com>
date Tue, 15 Jul 2008 14:27:37 +0000
parents 156746a63a5c
children
line wrap: on
line diff
--- a/Lib/UserString.py	Tue Jul 15 13:47:33 2008 +0000
+++ b/Lib/UserString.py	Tue Jul 15 14:27:37 2008 +0000
@@ -150,8 +150,10 @@
         warnpy3k('the class UserString.MutableString has been removed in '
                     'Python 3.0', stacklevel=2)
         self.data = string
-    def __hash__(self):
-        raise TypeError, "unhashable type (it is mutable)"
+
+    # We inherit object.__hash__, so we must deny this explicitly
+    __hash__ = None
+
     def __setitem__(self, index, sub):
         if isinstance(index, slice):
             if isinstance(sub, UserString):