From 0147a761b1751a833bb11e176833be7082322b86 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 19 Jul 2008 14:14:06 +0000 Subject: Merged revisions 65137 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r65137 | georg.brandl | 2008-07-19 08:32:57 -0500 (Sat, 19 Jul 2008) | 2 lines #3334: correctly set prefix of imports. ........ --- Lib/lib2to3/fixes/fix_import.py | 2 +- Lib/lib2to3/tests/test_fixers.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Lib/lib2to3/fixes/fix_import.py b/Lib/lib2to3/fixes/fix_import.py index 259ddc8..1fa465c 100644 --- a/Lib/lib2to3/fixes/fix_import.py +++ b/Lib/lib2to3/fixes/fix_import.py @@ -45,7 +45,7 @@ class FixImport(fixer_base.BaseFix): node.changed() else: new = FromImport('.', getattr(imp, 'content', None) or [imp]) - new.prefix = node.get_prefix() + new.set_prefix(node.get_prefix()) node = new return node diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py index eccbfc0..f5aaa8d 100755 --- a/Lib/lib2to3/tests/test_fixers.py +++ b/Lib/lib2to3/tests/test_fixers.py @@ -3319,6 +3319,17 @@ class Test_import(FixerTestCase): a = "from . import foo.bar as bang" self.check_both(b, a) + def test_prefix(self): + b = """ + # prefix + import foo.bar + """ + a = """ + # prefix + from . import foo.bar + """ + self.check_both(b, a) + if __name__ == "__main__": import __main__ -- cgit v0.12