#10360: catch TypeError in WeakSet.__contains__, just like WeakKeyDictionary does.

This commit is contained in:
Georg Brandl 2010-12-03 07:55:44 +00:00
parent 3b9406b08a
commit f8de3fea12
3 changed files with 10 additions and 2 deletions

View file

@ -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),),