Message257303
> I don’t think you need to define __len__() to get an iterable, only __getitem__().
The "old-style sequence protocol" means having a __getitem__ that works for values from 0 to __len__() and raises IndexError at __len__(). You don't need to be a complete old-style sequence to be iterable; just having __getitem__ makes you iterable (without being a collections.abc.Iterable or a typing.Iterable), and having __getitem__ and __len__ makes you reversible (without being a typing.Reversible). At any rate, this bug isn't about avoiding false negatives for the implicit ABCs, but false positives: defining __iter__ = None blocks the old-style sequence protocol, but makes isinstance(Iterable) true. |
|
Date |
User |
Action |
Args |
2016-01-01 21:25:14 | abarnert | set | recipients:
+ abarnert, ncoghlan, r.david.murray, martin.panter, serhiy.storchaka |
2016-01-01 21:25:14 | abarnert | set | messageid: <1451683514.66.0.370992724909.issue25958@psf.upfronthosting.co.za> |
2016-01-01 21:25:14 | abarnert | link | issue25958 messages |
2016-01-01 21:25:14 | abarnert | create | |
|