Issue 12613: itertools fixer fails
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) * ![]() |
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) * ![]() |
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:20 | admin | set | github: 56822 |
| 2021-10-20 23:00:55 | iritkatriel | set | status: open -> closed superseder: Close 2to3 issues and list them here resolution: wont fix stage: patch review -> resolved |
| 2019-03-15 23:53:58 | BreamoreBoy | set | nosy:
- BreamoreBoy |
| 2014-06-26 15:23:07 | berker.peksag | set | versions: + Python 3.5, - Python 3.2, Python 3.3 |
| 2014-06-26 14:52:17 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg221605 |
| 2013-01-04 17:37:03 | serhiy.storchaka | set | keywords:
+ needs review versions: + Python 3.4 |
| 2011-08-11 04:13:20 | meador.inge | set | files:
+ issue12613.patch messages: + msg141893 keywords:
+ patch |
| 2011-08-10 20:29:18 | meador.inge | set | nosy:
+ meador.inge |
| 2011-08-09 18:44:21 | petri.lehtinen | set | messages: + msg141836 |
| 2011-08-09 18:20:51 | petri.lehtinen | set | nosy:
+ petri.lehtinen |
| 2011-07-25 23:06:18 | Aaron.Meurer | set | nosy:
+ Aaron.Meurer |
| 2011-07-23 02:52:12 | rhettinger | set | priority: normal -> high |
| 2011-07-22 21:19:04 | eric.araujo | set | nosy:
+ eric.araujo stage: needs patch versions: + Python 3.3 |
| 2011-07-22 16:56:09 | vstinner | set | nosy:
+ benjamin.peterson |
| 2011-07-22 16:49:31 | VPeric | create | |
