Index: lib2to3/tests/test_fixers.py =================================================================== --- lib2to3/tests/test_fixers.py (revision 65144) +++ lib2to3/tests/test_fixers.py (working copy) @@ -1119,6 +1119,9 @@ s = "s = %s(d.items())" % wrapper self.unchanged(s) + for meth in ("keys", "values", "items"): + s = "for i in d.%s(): pass" % meth + self.unchanged(s) def test_01(self): b = "d.keys()" @@ -1173,74 +1176,55 @@ self.check(b, a) def test_11(self): - b = "for i in d.keys(): print i" - a = "for i in list(d.keys()): print i" - self.check(b, a) - - def test_12(self): b = "for i in d.iterkeys(): print i" a = "for i in d.keys(): print i" self.check(b, a) def test_13(self): - b = "[i for i in d.keys()]" - a = "[i for i in list(d.keys())]" - self.check(b, a) - - def test_14(self): b = "[i for i in d.iterkeys()]" a = "[i for i in d.keys()]" self.check(b, a) def test_15(self): - b = "(i for i in d.keys())" - a = "(i for i in list(d.keys()))" - self.check(b, a) - - def test_16(self): b = "(i for i in d.iterkeys())" a = "(i for i in d.keys())" self.check(b, a) - def test_17(self): + def test_16(self): b = "iter(d.iterkeys())" a = "iter(d.keys())" self.check(b, a) - def test_18(self): + def test_17(self): b = "list(d.iterkeys())" a = "list(d.keys())" self.check(b, a) - def test_19(self): + def test_18(self): b = "sorted(d.iterkeys())" a = "sorted(d.keys())" self.check(b, a) - def test_20(self): + def test_19(self): b = "foo(d.iterkeys())" a = "foo(iter(d.keys()))" self.check(b, a) - def test_21(self): + def test_20(self): b = "print h.iterkeys().next()" a = "print iter(h.keys()).next()" self.check(b, a) - def test_22(self): + def test_21(self): b = "print h.keys()[0]" a = "print list(h.keys())[0]" self.check(b, a) - def test_23(self): + def test_22(self): b = "print list(h.iterkeys().next())" a = "print list(iter(h.keys()).next())" self.check(b, a) - def test_24(self): - b = "for x in h.keys()[0]: print x" - a = "for x in list(h.keys())[0]: print x" - self.check(b, a) class Test_xrange(FixerTestCase): fixer = "xrange" Index: lib2to3/fixes/fix_dict.py =================================================================== --- lib2to3/fixes/fix_dict.py (revision 65144) +++ lib2to3/fixes/fix_dict.py (working copy) @@ -93,7 +93,5 @@ else: # list(d.keys()) -> list(d.keys()), etc. return results["func"].value in fixer_util.consuming_calls - if not isiter: - return False # for ... in d.iterkeys() -> for ... in d.keys(), etc. return self.p2.match(node.parent, results) and results["node"] is node