Author abarnert
Recipients abarnert, ncoghlan, serhiy.storchaka
Date 2015-12-28.20:56:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1451336205.63.0.344936098128.issue25958@psf.upfronthosting.co.za>
In-reply-to
Content
Hashable and Awaitable already treat None (actually any falsey value) as not implementing the special method, and blocking any superclass implementation, in their __subclasshook__. (This only blocks implicit subclassing--anything that actually directly or indirectly inherits from or registers with Hashable is still Hashable even if it sets __hash__ = None.)

Coroutine, AsyncIterable, AsyncIterator, Iterable, Iterator, Generator, Sized, Container, and Callable treat None as an implementation.

http://bugs.python.org/file41440/cpython-iter-patch.diff for #25864 changes Iterable to work like Hashable, but doesn't touch any of the other types.

To fix this in general, just apply the same change to the other implicit ABCs (and probably factor out the logic instead of repeating it that many more times).

But I'm not sure a general fix is needed here. The special methods for those other types don't have a base class and/or fallback implementation to block the way __hash__, __iter__, and __reversed__ do (except for __call__ on metaclasses, but I can't imagine why you'd want a metaclass that isn't callable), so there's no need to set them to None to block that, so the problem should never come up.
History
Date User Action Args
2015-12-28 20:56:45abarnertsetrecipients: + abarnert, ncoghlan, serhiy.storchaka
2015-12-28 20:56:45abarnertsetmessageid: <1451336205.63.0.344936098128.issue25958@psf.upfronthosting.co.za>
2015-12-28 20:56:45abarnertlinkissue25958 messages
2015-12-28 20:56:45abarnertcreate