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: 2to3 does not fix zip in some cases
Type: Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.4
process
Status: closed Resolution: duplicate
Dependencies: Superseder: 2to3 zip fixer doesn't fix for loops.
View: 20742
Assigned To: Nosy List: RobertG, benjamin.peterson, berker.peksag, stuarteberg
Priority: normal Keywords:

Created on 2014-06-01 17:27 by RobertG, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg219511 - (view) Author: RobertG (RobertG) Date: 2014-06-01 17:27
Consider this program

def foo(a,b):
	return min(zip(a,b)[2])

print foo(range(5), (0,9,-9))

With the default options, 2to3 rewrites this as

def foo(a,b):
	return min(zip(a,b)[2])

print(foo(list(range(5)), (0,9,-9)))

For some reason, 2to3 fails to wrap the call to zip in a list, even though the 2to3 documentation says that there is a fixer which does this. Obviously, the generated code will not work in Python 3 since you can't subscript an iterator.
msg219568 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-06-02 11:15
This is a duplicate of issue 20742.
msg285793 - (view) Author: Stuart Berg (stuarteberg) * Date: 2017-01-19 14:45
Already closed, but FWIW, I think this was incorrectly marked as a duplicate.  Issue 20742 discusses a different issue related to lib2to3 and zip.

Meanwhile, this issue has been raised again in 28837, so I will continue the discussion there.  (I have a patch.)
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65827
2017-01-19 14:45:23stuartebergsetnosy: + stuarteberg
messages: + msg285793
2014-06-02 11:15:08berker.peksagsetstatus: open -> closed

superseder: 2to3 zip fixer doesn't fix for loops.

nosy: + berker.peksag
messages: + msg219568
resolution: duplicate
stage: resolved
2014-06-01 18:53:27serhiy.storchakasetnosy: + benjamin.peterson
2014-06-01 17:27:53RobertGcreate