You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
2to3 should treat enumerate like sorted for zip, map, filter, dict, xrange #60777
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2012-11-29.15:58:59.066>created_at=<Date2012-11-28.23:58:00.196>labels= ['type-bug', 'expert-2to3']
title='2to3 should treat enumerate like sorted for zip, map, filter, dict, xrange'updated_at=<Date2012-11-29.15:58:59.064>user='https://bugs.python.org/jpkotta'
enumerate() is a "consuming_call", as defined in fixer_util.py, because it takes an iterable (not necessarily a collection). Therefore whenever we have something like enumerate(zip(...)), we don't need to replace it with enumerate(list(zip(...))) in 2to3, because enumerate doesn't care that zip no longer returns a list.
Activity
jpkotta commentedon Nov 28, 2012
enumerate() is a "consuming_call", as defined in fixer_util.py, because it takes an iterable (not necessarily a collection). Therefore whenever we have something like enumerate(zip(...)), we don't need to replace it with enumerate(list(zip(...))) in 2to3, because enumerate doesn't care that zip no longer returns a list.
Patch attached.
benjaminp commentedon Nov 29, 2012
Thanks for the patch.
python-dev commentedon Nov 29, 2012
New changeset 3c6d8461b09f by Benjamin Peterson in branch '3.2':
enumerate only requires an iterable (closes bpo-16573)
http://hg.python.org/cpython/rev/3c6d8461b09f
New changeset 4ff17cf130eb by Benjamin Peterson in branch '3.3':
merge 3.2 (bpo-16573)
http://hg.python.org/cpython/rev/4ff17cf130eb
New changeset 2bb604a691de by Benjamin Peterson in branch '2.7':
enumerate only requires an iterable (closes bpo-16573)
http://hg.python.org/cpython/rev/2bb604a691de
New changeset ce3f0399ea33 by Benjamin Peterson in branch 'default':
merge 3.3 (bpo-16573)
http://hg.python.org/cpython/rev/ce3f0399ea33