[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2020-07-05 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset e51dd9dad6590bf3a940723fbbaaf4f64a3c9228 by Pablo Galindo in 
branch 'master':
bpo-29727: Register array.array as a MutableSequence (GH-21338)
https://github.com/python/cpython/commit/e51dd9dad6590bf3a940723fbbaaf4f64a3c9228


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2020-07-05 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2020-07-05 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +patch
nosy: +pablogsal
nosy_count: 5.0 -> 6.0
pull_requests: +20486
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/21338

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-04-26 Thread Ivan Levkivskyi

Changes by Ivan Levkivskyi :


--
assignee:  -> levkivskyi
stage:  -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-04-25 Thread Guido van Rossum

Guido van Rossum added the comment:

I'm with Raymond.

I propose to register array.array() in all the appropriate places and then 
close this bug as a won't fix.

The typing issue might eventually be resolved via PEP 544 (if accepted), or not 
-- the"fallback protocols" based on __getitem__ and __len__ seem to be a 
complicating special case that we may want to put off.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-04-25 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-03-05 Thread Ivan Levkivskyi

Changes by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-03-05 Thread Raymond Hettinger

Raymond Hettinger added the comment:

One other thought:  array.array() object should probably be registered so that 
it recognizable as a Sequence and as Reversible.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-03-05 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I don't think this is a bug.  The purpose collections.abc.Reversible is to 
recognize type where the behavior has been guaranteed, not to recognize all 
types where it happens to work.

Part of the original reason for introducing ABCs in the first place was that in 
general there is no reliable way to detect whether a class defining __getitem__ 
is a sequence or a mapping.

A creator of such a class either needs to subclass from Sequence or register as 
a Sequence.  The fact that reversed(Counter(10)) happens to work is no more 
interesting that the fact Counter(10)[5] happens to work eventhough 
isinstance(Counter, Sequence) returns False.

--
assignee:  -> rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29727] collections.abc.Reversible doesn't fully support the reversing protocol

2017-03-05 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

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.

--
components: Library (Lib)
messages: 289039
nosy: gvanrossum, rhettinger, serhiy.storchaka, stutzbach
priority: normal
severity: normal
status: open
title: collections.abc.Reversible doesn't fully support the reversing protocol
type: behavior
versions: Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com