Author serhiy.storchaka
Recipients donkopotamus, fdrake, pitrou, rhettinger, serhiy.storchaka, stutzbach
Date 2017-04-19.08:30:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492590653.65.0.763316100783.issue30100@psf.upfronthosting.co.za>
In-reply-to
Content
What about difference_update(), issubset(), issuperset(), __eq__()?

Raising TypeError looks reasonable to me. Operations with ordinal sets can raise TypeError for unhashable values.

>>> [] in set()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
>>> set().remove([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
>>> set().discard([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'

Unlike to set.__contains__ WeakSet.__contains__ returns False for unsupported types:

>>> [] in weakref.WeakSet()
False

Shouldn't set.__contains__ be changed to return False for unhashable values? Or may be make WeakSet.__contains__ raising TypeError for values that can't have weak references?
History
Date User Action Args
2017-04-19 08:30:53serhiy.storchakasetrecipients: + serhiy.storchaka, fdrake, rhettinger, pitrou, stutzbach, donkopotamus
2017-04-19 08:30:53serhiy.storchakasetmessageid: <1492590653.65.0.763316100783.issue30100@psf.upfronthosting.co.za>
2017-04-19 08:30:53serhiy.storchakalinkissue30100 messages
2017-04-19 08:30:53serhiy.storchakacreate