mirror of
https://github.com/python/cpython.git
synced 2025-10-08 08:01:55 +00:00
#10360: catch TypeError in WeakSet.__contains__, just like WeakKeyDictionary does.
This commit is contained in:
parent
3b9406b08a
commit
f8de3fea12
3 changed files with 10 additions and 2 deletions
|
@ -66,7 +66,11 @@ class WeakSet:
|
|||
return sum(x() is not None for x in self.data)
|
||||
|
||||
def __contains__(self, item):
|
||||
return ref(item) in self.data
|
||||
try:
|
||||
wr = ref(item)
|
||||
except TypeError:
|
||||
return False
|
||||
return wr in self.data
|
||||
|
||||
def __reduce__(self):
|
||||
return (self.__class__, (list(self),),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue