[issue5786] len(reversed([1,2,3])) does not work anymore in 2.6.2

seesee report at bugs.python.org
Sat Apr 18 18:00:28 CEST 2009


New submission from seesee <cthedot at gmail.com>:

It seems python 2.6.2 (at least under Windows, I have not tested other
platforms) does break the len function on the reversed iterator:

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> len(reversed([1,2,3]))
3

Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> len(reversed([1,2,3]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object of type 'listreverseiterator' has no len()

I don't think it was meant to work but it did in Python 2.6.1 (and 2.5
as shown above). I guess it has something to do with Issue #3689 and
guess __len__ was simply removed. 

Problem really is that Python 2.6.2 breaks backwards compatibility.

----------
components: Windows
messages: 86122
nosy: seesee
severity: normal
status: open
title: len(reversed([1,2,3])) does not work anymore in 2.6.2
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5786>
_______________________________________


More information about the Python-bugs-list mailing list