summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/fixes/fix_imports.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/lib2to3/fixes/fix_imports.py')
-rw-r--r--Lib/lib2to3/fixes/fix_imports.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/lib2to3/fixes/fix_imports.py b/Lib/lib2to3/fixes/fix_imports.py
index 75770c9..98d4406 100644
--- a/Lib/lib2to3/fixes/fix_imports.py
+++ b/Lib/lib2to3/fixes/fix_imports.py
@@ -118,7 +118,7 @@ class FixImports(fixer_base.BaseFix):
def transform(self, node, results):
import_mod = results.get("module_name")
if import_mod:
- new_name = self.mapping[(import_mod or mod_name).value]
+ new_name = self.mapping[import_mod.value]
import_mod.replace(Name(new_name, prefix=import_mod.get_prefix()))
if "name_import" in results:
# If it's not a "from x import x, y" or "import x as y" import,
@@ -129,10 +129,8 @@ class FixImports(fixer_base.BaseFix):
# line (e.g., "import StringIO, urlparse"). The problem is that I
# can't figure out an easy way to make a pattern recognize the
# keys of MAPPING randomly sprinkled in an import statement.
- while True:
- results = self.match(node)
- if not results:
- break
+ results = self.match(node)
+ if results:
self.transform(node, results)
else:
# Replace usage of the module.