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: itertools fixer fails
Type: behavior Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder: Close 2to3 issues and list them here
View: 45544
Assigned To: Nosy List: Aaron.Meurer, VPeric, benjamin.peterson, eric.araujo, meador.inge, petri.lehtinen
Priority: high Keywords: needs review, patch

Created on 2011年07月22日 16:49 by VPeric, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue12613.patch meador.inge, 2011年08月11日 04:13 Patch against 2to3 tip
Messages (4)
msg140897 - (view) Author: Vlada Peric (VPeric) Date: 2011年07月22日 16:49
The itertools fixer (izip -> zip, among others), fails for the following code:
from itertools import izip
print msg % str(bool(symbol_swapped) and list(izip(*swap_dict).next()) or symbols)
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.
msg141836 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011年08月09日 18:44
A smaller snippet to reproduce:
 izip().next()
This gets converted to:
 next(izip())
It seems to me that the pattern of the itertools fixer doesn't match to izip().something(), and thus this is skipped.
msg141893 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2011年08月11日 04:13
I see two problems that cause the posted test cases to fail:
 1. The 'next' fixer runs before the 'itertools' fixer and strips
 out a 'power' node. This keeps the 'itertools' fixer from
 matching.
 2. 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.
msg221605 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014年06月26日 14:52
The patch is small and looks clean to me. Can someone take a look with a view to committing please, thanks.
History
Date User Action Args
2022年04月11日 14:57:20adminsetgithub: 56822
2021年10月20日 23:00:55iritkatrielsetstatus: open -> closed
superseder: Close 2to3 issues and list them here
resolution: wont fix
stage: patch review -> resolved
2019年03月15日 23:53:58BreamoreBoysetnosy: - BreamoreBoy
2014年06月26日 15:23:07berker.peksagsetversions: + Python 3.5, - Python 3.2, Python 3.3
2014年06月26日 14:52:17BreamoreBoysetnosy: + BreamoreBoy
messages: + msg221605
2013年01月04日 17:37:03serhiy.storchakasetkeywords: + needs review
versions: + Python 3.4
2011年08月11日 04:13:20meador.ingesetfiles: + issue12613.patch
messages: + msg141893

keywords: + patch
type: behavior
stage: needs patch -> patch review
2011年08月10日 20:29:18meador.ingesetnosy: + meador.inge
2011年08月09日 18:44:21petri.lehtinensetmessages: + msg141836
2011年08月09日 18:20:51petri.lehtinensetnosy: + petri.lehtinen
2011年07月25日 23:06:18Aaron.Meurersetnosy: + Aaron.Meurer
2011年07月23日 02:52:12rhettingersetpriority: normal -> high
2011年07月22日 21:19:04eric.araujosetnosy: + eric.araujo
stage: needs patch

versions: + Python 3.3
2011年07月22日 16:56:09vstinnersetnosy: + benjamin.peterson
2011年07月22日 16:49:31VPericcreate

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