[Python-checkins] r82855 - in sandbox/trunk/2to3/lib2to3: fixes/fix_itertools_imports.py tests/test_fixers.py

benjamin.peterson python-checkins at python.org
Tue Jul 13 23:27:38 CEST 2010


Author: benjamin.peterson
Date: Tue Jul 13 23:27:38 2010
New Revision: 82855

Log:
remove more extraneous commas #9245

Modified:
   sandbox/trunk/2to3/lib2to3/fixes/fix_itertools_imports.py
   sandbox/trunk/2to3/lib2to3/tests/test_fixers.py

Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_itertools_imports.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/fixes/fix_itertools_imports.py	(original)
+++ sandbox/trunk/2to3/lib2to3/fixes/fix_itertools_imports.py	Tue Jul 13 23:27:38 2010
@@ -43,8 +43,8 @@
             else:
                 remove_comma ^= True
 
-        if children[-1].type == token.COMMA:
-            children[-1].remove()
+        while children and children[-1].type == token.COMMA:
+            children.pop().remove()
 
         # If there are no imports left, just get rid of the entire statement
         if (not (imports.children or getattr(imports, 'value', None)) or

Modified: sandbox/trunk/2to3/lib2to3/tests/test_fixers.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/tests/test_fixers.py	(original)
+++ sandbox/trunk/2to3/lib2to3/tests/test_fixers.py	Tue Jul 13 23:27:38 2010
@@ -3623,6 +3623,10 @@
         a = "from itertools import bar, foo"
         self.check(b, a)
 
+        b = "from itertools import chain, imap, izip"
+        a = "from itertools import chain"
+        self.check(b, a)
+
     def test_comments(self):
         b = "#foo\nfrom itertools import imap, izip"
         a = "#foo\n"


More information about the Python-checkins mailing list