diff options
| author | Nick Coghlan <ncoghlan@gmail.com> | 2008-07-15 14:27:37 (GMT) | 
|---|---|---|
| committer | Nick Coghlan <ncoghlan@gmail.com> | 2008-07-15 14:27:37 (GMT) | 
| commit | 53663a695ef2bb96ac0252cd4cc4aa40d4f953be (patch) | |
| tree | e241ef71b353f8b3162179b1eed5a3f4eaae0c5f /Lib/UserString.py | |
| parent | 9ace15ca25e1e72e1b943190a5f4efbd7d118de3 (diff) | |
| download | cpython-53663a695ef2bb96ac0252cd4cc4aa40d4f953be.zip cpython-53663a695ef2bb96ac0252cd4cc4aa40d4f953be.tar.gz cpython-53663a695ef2bb96ac0252cd4cc4aa40d4f953be.tar.bz2  | |
Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful
Diffstat (limited to 'Lib/UserString.py')
| -rwxr-xr-x | Lib/UserString.py | 6 | 
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/UserString.py b/Lib/UserString.py index 4460797..726b3f7 100755 --- a/Lib/UserString.py +++ b/Lib/UserString.py @@ -150,8 +150,10 @@ class MutableString(UserString, collections.MutableSequence):          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):  | 
