homepage

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

AltStyle によって変換されたページ (->オリジナル) /