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

benjamin.peterson python-checkins at python.org
Mon Nov 10 22:29:58 CET 2008


Author: benjamin.peterson
Date: Mon Nov 10 22:29:58 2008
New Revision: 67179

Log:
allow the fix_import pattern to catch from imports with parenthesis

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

Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_import.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/fixes/fix_import.py	(original)
+++ sandbox/trunk/2to3/lib2to3/fixes/fix_import.py	Mon Nov 10 22:29:58 2008
@@ -18,7 +18,7 @@
 class FixImport(fixer_base.BaseFix):
 
     PATTERN = """
-    import_from< type='from' imp=any 'import' any >
+    import_from< type='from' imp=any 'import' ['('] any [')'] >
     |
     import_name< type='import' imp=any >
     """

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	Mon Nov 10 22:29:58 2008
@@ -3347,6 +3347,10 @@
         a = "from .foo import bar"
         self.check_both(b, a)
 
+        b = "from foo import (bar, baz)"
+        a = "from .foo import (bar, baz)"
+        self.check_both(b, a)
+
     def test_dotted_from(self):
         b = "from green.eggs import ham"
         a = "from .green.eggs import ham"


More information about the Python-checkins mailing list