This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients gvanrossum, rhettinger, serhiy.storchaka, stutzbach
Date 2017-03-05.18:49:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488739763.14.0.639498346483.issue29727@psf.upfronthosting.co.za>
In-reply-to
Content
collections.abc.Reversible doesn't work with types that are supported by reserved() but neither have the __reversed__ method nor are explicitly registered as collections.abc.Sequence. For example:

>>> issubclass(array.array, collections.abc.Reversible)
False 

The reversing protocol as well as the iterating protocol is supported not only by special method, but implicitly if the class has implemented __getitem__ and __len__ methods.

>>> class Counter(int):
...   def __getitem__(s, i): return i
...   def __len__(s): return s
... 
>>> list(reversed(Counter(10)))
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
>>> issubclass(Counter, collections.abc.Reversible)
False

typing.Reversible starves from the same bug. See https://github.com/python/typing/issues/170.
History
Date User Action Args
2017-03-05 18:49:23serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, rhettinger, stutzbach
2017-03-05 18:49:23serhiy.storchakasetmessageid: <1488739763.14.0.639498346483.issue29727@psf.upfronthosting.co.za>
2017-03-05 18:49:23serhiy.storchakalinkissue29727 messages
2017-03-05 18:49:22serhiy.storchakacreate