mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful
This commit is contained in:
parent
9ace15ca25
commit
53663a695e
14 changed files with 134 additions and 134 deletions
|
@ -439,10 +439,8 @@ class Set(BaseSet):
|
|||
def __setstate__(self, data):
|
||||
self._data, = data
|
||||
|
||||
def __hash__(self):
|
||||
"""A Set cannot be hashed."""
|
||||
# We inherit object.__hash__, so we must deny this explicitly
|
||||
raise TypeError, "Can't hash a Set, only an ImmutableSet."
|
||||
# We inherit object.__hash__, so we must deny this explicitly
|
||||
__hash__ = None
|
||||
|
||||
# In-place union, intersection, differences.
|
||||
# Subtle: The xyz_update() functions deliberately return None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue