[Python-checkins] r67177 - in sandbox/trunk/2to3/lib2to3: fixes/fix_metaclass.py tests/test_fixers.py

benjamin.peterson python-checkins at python.org
Mon Nov 10 04:52:53 CET 2008


Author: benjamin.peterson
Date: Mon Nov 10 04:52:52 2008
New Revision: 67177

Log:
let the metclass fixer handle complex assignments in the class body gracefully

Modified:
   sandbox/trunk/2to3/lib2to3/fixes/fix_metaclass.py
   sandbox/trunk/2to3/lib2to3/tests/test_fixers.py

Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_metaclass.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/fixes/fix_metaclass.py	(original)
+++ sandbox/trunk/2to3/lib2to3/fixes/fix_metaclass.py	Mon Nov 10 04:52:52 2008
@@ -35,8 +35,9 @@
         elif node.type == syms.simple_stmt and node.children:
             expr_node = 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__':
+                left_side = expr_node.children[0]
+                if isinstance(left_side, Leaf) and \
+                        left_side.value == '__metaclass__':
                     return True
     return False
 

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	Mon Nov 10 04:52:52 2008
@@ -3626,6 +3626,12 @@
         """
         self.unchanged(s)
 
+        s = """
+        class X:
+            a[23] = 74
+        """
+        self.unchanged(s)
+
     def test_comments(self):
         b = """
         class X:


More information about the Python-checkins mailing list