summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/fixes
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-11-25 03:08:21 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-11-25 03:08:21 (GMT)
commit64903f9ed9e46741fa096925c97dad2d2b5c984d (patch)
tree64debfc5dcb8fa8d97703a382e47ce89b5bc5914 /Lib/lib2to3/fixes
parent2b5d6ebfe5b6477cb5d5b6cd043c6350910b5656 (diff)
downloadcpython-64903f9ed9e46741fa096925c97dad2d2b5c984d.zip
cpython-64903f9ed9e46741fa096925c97dad2d2b5c984d.tar.gz
cpython-64903f9ed9e46741fa096925c97dad2d2b5c984d.tar.bz2
Merged revisions 67183,67191,67371 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r67183 | benjamin.peterson | 2008-11-11 04:51:33 +0100 (Di, 11 Nov 2008) | 1 line handle 'import x as y' in fix_imports; this still needs more work... ........ r67191 | benjamin.peterson | 2008-11-12 00:24:51 +0100 (Mi, 12 Nov 2008) | 1 line super() is good ........ r67371 | benjamin.peterson | 2008-11-24 23:02:00 +0100 (Mo, 24 Nov 2008) | 1 line don't blow up in the metaclass fixer when assignments in the class statement aren't simple ........
Diffstat (limited to 'Lib/lib2to3/fixes')
-rw-r--r--Lib/lib2to3/fixes/fix_import.py7
-rw-r--r--Lib/lib2to3/fixes/fix_metaclass.py7
2 files changed, 10 insertions, 4 deletions
diff --git a/Lib/lib2to3/fixes/fix_import.py b/Lib/lib2to3/fixes/fix_import.py
index cc744f2..c065f70 100644
--- a/Lib/lib2to3/fixes/fix_import.py
+++ b/Lib/lib2to3/fixes/fix_import.py
@@ -13,7 +13,7 @@ Becomes:
# Local imports
from .. import fixer_base
from os.path import dirname, join, exists, pathsep
-from ..fixer_util import FromImport
+from ..fixer_util import FromImport, syms
class FixImport(fixer_base.BaseFix):
@@ -26,11 +26,14 @@ class FixImport(fixer_base.BaseFix):
def transform(self, node, results):
imp = results['imp']
+ mod_name = str(imp.children[0] if imp.type == syms.dotted_as_name \
+ else imp)
+
if str(imp).startswith('.'):
# Already a new-style import
return
- if not probably_a_local_import(str(imp), self.filename):
+ if not probably_a_local_import(str(mod_name), self.filename):
# I guess this is a global import -- skip it!
return
diff --git a/Lib/lib2to3/fixes/fix_metaclass.py b/Lib/lib2to3/fixes/fix_metaclass.py
index c2f4b7f..b508f5f 100644
--- a/Lib/lib2to3/fixes/fix_metaclass.py
+++ b/Lib/lib2to3/fixes/fix_metaclass.py
@@ -110,8 +110,11 @@ def find_metas(cls_node):
if simple_node.type == syms.simple_stmt and simple_node.children:
expr_node = simple_node.children[0]
if expr_node.type == syms.expr_stmt and expr_node.children:
- leaf_node = expr_node.children[0]
- if leaf_node.value == '__metaclass__':
+ # Check if the expr_node is a simple assignment.
+ left_node = expr_node.children[0]
+ if isinstance(left_node, Leaf) and \
+ left_node.value == '__metaclass__':
+ # We found a assignment to __metaclass__.
fixup_simple_stmt(node, i, simple_node)
remove_trailing_newline(simple_node)
yield (node, i, simple_node)