[Python-checkins] r65137 - in sandbox/trunk/2to3/lib2to3: fixes/fix_import.py tests/test_fixers.py
georg.brandl
python-checkins at python.org
Sat Jul 19 15:32:58 CEST 2008
Author: georg.brandl
Date: Sat Jul 19 15:32:57 2008
New Revision: 65137
Log:
#3334: correctly set prefix of imports.
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 Sat Jul 19 15:32:57 2008
@@ -45,7 +45,7 @@
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
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 Sat Jul 19 15:32:57 2008
@@ -3317,6 +3317,17 @@
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__
More information about the Python-checkins
mailing list