Message257128
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). |
|
Date |
User |
Action |
Args |
2015-12-28 20:38:44 | abarnert | set | recipients:
+ abarnert, gvanrossum, rhettinger, terry.reedy, ncoghlan, r.david.murray, serhiy.storchaka, abarry, curioswati |
2015-12-28 20:38:44 | abarnert | set | messageid: <1451335124.13.0.589752399479.issue25864@psf.upfronthosting.co.za> |
2015-12-28 20:38:44 | abarnert | link | issue25864 messages |
2015-12-28 20:38:43 | abarnert | create | |
|