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.

classification
Title: len(reversed(
Type: behavior Stage: commit review
Components: Versions: Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, barry, georg.brandl, giampaolo.rodola, mark.dickinson, pitrou, rhettinger, seesee
Priority: release blocker Keywords:

Created on 2009-04-18 16:00 by seesee, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (14)
msg86122 - (view) Author: Christof (seesee) Date: 2009-04-18 16:00
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.
msg86130 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-18 18:10
Raymond, this was your change in r67478 (backported to trunk in r67498).
msg86143 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-04-18 23:30
Guido decided that iterators should not support len() because he wanted
bool(it) to always be True.
msg86145 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-04-18 23:37
Uh, perhaps the behaviour wasn't optimal but breaking compatibility
between two bugfix releases isn't developer-friendly either.

While we could keep it in trunk, it sounds like the change should be
reverted in 2.6.
The backport to 2.6 was done by Georg in r67569, by the way :-)
msg86153 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-04-19 01:42
It's up to you guys.  I had thought to change it only for Py2.7 but
Guido probably considers it to be a bug, so possibly the backport was
justified.
msg86159 - (view) Author: Christof (seesee) Date: 2009-04-19 09:37
A compatibility break in a minor bugfix version is never a good idea I
guess. I understand the reasoning but this change may break quite a few
packages (at least it broke mine). A workaround in programs is easy but
for already released and deployed versions simply not possible. A change
for Python 2.7 would be at least annoying too but I guess could be
justified. Just my thoughts...
msg86166 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-19 11:41
Is there a 2.6 release imminent?  I thought I saw some discussion of a 
2.6.3 release, but I'm not sure what the eventual decision was. If so, 
perhaps this change could be quickly reverted in the release26-maint 
branch?
msg86172 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-04-19 15:16
Setting as a release blocker so Barry can consider this for 2.6.3
(-committers seems to suggest that it'll be released soon).
msg86252 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-04-21 17:55
Essentially, the only argument for reverting this is breaking
compatibility with 2.6.0 and 2.6.1.  But, in the process, reverting it
means breaking compatibility with 2.6.2.  Since the cat is already out
of the bag for 2.6.2, I think the bugfix ought to be left in-place. 
It's too disruptive to switch back and forth during micro releases.
msg86255 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-21 18:19
If 2.6.3 isn't imminent, I agree this change should be left in place.
msg87862 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-05-16 08:33
Is it okay with everyone to close this as "wont fix"?  (BTW, is there
some reason that the Resolution field isn't allowed to have an
apostrophe in it?)  There's nothing we can do about 2.6.2;  it appears
2.6.3 wasn't imminent, and as Raymond says it seems disruptive to
switch it back now.
msg87868 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-16 09:07
> Is it okay with everyone to close this as "wont fix"?  (BTW, is there
> some reason that the Resolution field isn't allowed to have an
> apostrophe in it?)  There's nothing we can do about 2.6.2;  it appears
> 2.6.3 wasn't imminent, and as Raymond says it seems disruptive to
> switch it back now.

Well, the harm is done, unfortunately, and both resolutions have
analogous downsides, so we might indeed close it.
msg87869 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-16 09:11
Oh, answering by e-mail reopened the bug for some unknown reason.
msg87935 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-05-16 21:20
Closing.
History
Date User Action Args
2022-04-11 14:56:47adminsetnosy: + barry
github: 50036
2009-05-16 21:20:48mark.dickinsonsetstatus: pending -> closed
resolution: wont fix
messages: + msg87935
2009-05-16 09:11:27pitrousetstatus: open -> pending

messages: + msg87869
2009-05-16 09:07:02pitrousetstatus: pending -> open

messages: + msg87868
title: len(reversed([1,2,3])) does not work anymore in 2.6.2 -> len(reversed(
2009-05-16 08:34:54mark.dickinsonsetstatus: open -> pending
2009-05-16 08:33:35mark.dickinsonsetmessages: + msg87862
2009-04-21 18:19:47mark.dickinsonsetmessages: + msg86255
2009-04-21 17:55:13rhettingersetmessages: + msg86252
2009-04-21 17:47:06giampaolo.rodolasetnosy: + giampaolo.rodola
2009-04-19 15:16:25ajaksu2setpriority: release blocker

nosy: + ajaksu2
messages: + msg86172

type: behavior
stage: commit review
2009-04-19 11:41:45mark.dickinsonsetnosy: + mark.dickinson
messages: + msg86166
2009-04-19 09:37:16seeseesetmessages: + msg86159
2009-04-19 01:42:28rhettingersetstatus: closed -> open
assignee: rhettinger ->
messages: + msg86153
2009-04-18 23:37:49pitrousetresolution: not a bug -> (no value)

messages: + msg86145
nosy: + pitrou
2009-04-18 23:30:52rhettingersetstatus: open -> closed
resolution: not a bug
messages: + msg86143
2009-04-18 18:10:11georg.brandlsetnosy: + georg.brandl
messages: + msg86130
2009-04-18 18:09:27benjamin.petersonsetassignee: rhettinger

nosy: + rhettinger
2009-04-18 17:19:25loewissetcomponents: - Windows
2009-04-18 16:00:27seeseecreate