summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/fixes/fix_metaclass.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-11-25 04:07:45 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-11-25 04:07:45 (GMT)
commitb38e325e97eb4f52cce10572d699d42105c91334 (patch)
tree887997def57844fe8b281bf06112560e8312c06b /Lib/lib2to3/fixes/fix_metaclass.py
parent9e6310d9368dad33af584c214af7ac8ea3cda0fc (diff)
downloadcpython-b38e325e97eb4f52cce10572d699d42105c91334.zip
cpython-b38e325e97eb4f52cce10572d699d42105c91334.tar.gz
cpython-b38e325e97eb4f52cce10572d699d42105c91334.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-10 21:51:33 -0600 (Mon, 10 Nov 2008) | 1 line handle 'import x as y' in fix_imports; this still needs more work... ........ r67191 | benjamin.peterson | 2008-11-11 17:24:51 -0600 (Tue, 11 Nov 2008) | 1 line super() is good ........ r67371 | benjamin.peterson | 2008-11-24 16:02:00 -0600 (Mon, 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/fix_metaclass.py')
-rw-r--r--Lib/lib2to3/fixes/fix_metaclass.py7
1 files changed, 5 insertions, 2 deletions
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)