BPO | [12613](https://bugs.python.org/issue12613) --- | :--- Nosy | @benjaminp, @merwok, @meadori, @asmeurer, @akheron Superseder | bpo-45544: Close 2to3 issues and list them here Files | [issue12613.patch](https://bugs.python.org/file22878/issue12613.patch "Uploaded as text/plain at 2011-08-11.04:13:19 by @meadori"): Patch against 2to3 tip *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: ```python assignee = None closed_at = created_at = labels = ['type-bug', 'expert-2to3'] title = 'itertools fixer fails' updated_at = user = 'https://bugs.python.org/VPeric' ``` bugs.python.org fields: ```python activity = actor = 'iritkatriel' assignee = 'none' closed = True closed_date = closer = 'iritkatriel' components = ['2to3 (2.x to 3.x conversion tool)'] creation = creator = 'VPeric' dependencies = [] files = ['22878'] hgrepos = [] issue_num = 12613 keywords = ['patch', 'needs review'] message_count = 4.0 messages = ['140897', '141836', '141893', '221605'] nosy_count = 6.0 nosy_names = ['benjamin.peterson', 'eric.araujo', 'VPeric', 'meador.inge', 'Aaron.Meurer', 'petri.lehtinen'] pr_nums = [] priority = 'high' resolution = 'wont fix' stage = 'resolved' status = 'closed' superseder = '45544' type = 'behavior' url = 'https://bugs.python.org/issue12613' versions = ['Python 2.7', 'Python 3.4', 'Python 3.5'] ```
Activity
VPeric commentedon Jul 22, 2011
The itertools fixer (izip -> zip, among others), fails for the following code:
It gets converted to:
print(msg % str(bool(symbol_swapped) and list(next(izip(*swap_dict))) or symbols))
(note how izip is still there)
I've worked aroudn this by introducing tmp = izip(...) and using that, but it'd be nice if 2to3 caught it by default.
akheron commentedon Aug 9, 2011
A smaller snippet to reproduce:
This gets converted to:
It seems to me that the pattern of the itertools fixer doesn't match to izip().something(), and thus this is skipped.
meadori commentedon Aug 11, 2011
I see two problems that cause the posted test cases to fail:
The 'next' fixer runs before the 'itertools' fixer and strips
out a 'power' node. This keeps the 'itertools' fixer from
matching.
The 'itertools' fixer does not handle any 'trailer' nodes after
the itertool function application it is transforming.
I have fixed both of these issues in the attached patch. Full test suite run; no regressions.
BreamoreBoy commentedon Jun 26, 2014
The patch is small and looks clean to me. Can someone take a look with a view to committing please, thanks.