◐ Shell
clean mode source ↗

Message 257128 - Python tracker

The attached patch does the following:

* collections.abc.Mapping.__reversed__ = None.

* collections.abc.Iterable.__subclasshook__ checks for None the same way Hashable does:

  * This tests for any falsey value, not just None. I'm not sure this is ideal, but it's consistent with Hashable, and it's unlikely to ever matter.

  * The test will only block implicit subclassing. If a class, e.g., inherits from tuple (which is explicitly registered with Sequence, which inherits from Iterable), it's Iterable, even if it sets __iter__ = None. I think this is the right behavior, and it's consistent with Hashable.

* iter and reversed add checks for None, which raise a TypeError with the appropriate message (instead of "'NoneType' is not callable").

* datamodel.rst section "Special method names" includes a paragraph on setting special methods to None.

* Tests for changes to reversed (in test_enumerate.py), iter (in test_iter.py), Iterable (in test_collections.py), and Mapping (in collections.py).