◐ Shell
clean mode source ↗

Issue 21628: 2to3 does not fix zip in some cases

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.
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.)