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),),
def test_contains(self):
for c in self.letters:
self.assertEqual(c in self.s, c in self.d)
- self.assertRaises(TypeError, self.s.__contains__, [[]])
+ # 1 is not weakref'able, but that TypeError is caught by __contains__
+ self.assertNotIn(1, self.s)
self.assertIn(self.obj, self.fs)
del self.obj
self.assertNotIn(ustr('F'), self.fs)
Library
-------
+- Issue #10360: In WeakSet, do not raise TypeErrors when testing for
+ membership of non-weakrefable objects.
+
- Issue #940286: pydoc.Helper.help() ignores input/output init parameters.
- Issue #1745035: Add a command size and data size limit to smtpd.py, to