[Python-checkins] r67178 - in sandbox/trunk/2to3/lib2to3: fixes/fix_metaclass.py tests/test_fixers.py
benjamin.peterson
python-checkins at python.org
Mon Nov 10 22:26:44 CET 2008
Author: benjamin.peterson
Date: Mon Nov 10 22:26:43 2008
New Revision: 67178
Log:
the metaclass fixers shouldn't die when bases are not a simple name
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 22:26:43 2008
@@ -166,12 +166,10 @@
if node.children[3].type == syms.arglist:
arglist = node.children[3]
# Node(classdef, ['class', 'name', '(', 'Parent', ')', ':', suite])
- elif isinstance(node.children[3], Leaf):
+ else:
parent = node.children[3].clone()
arglist = Node(syms.arglist, [parent])
node.set_child(3, arglist)
- else:
- raise ValueError("Unexpected class inheritance arglist")
elif len(node.children) == 6:
# Node(classdef, ['class', 'name', '(', ')', ':', suite])
# 0 1 2 3 4 5
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 22:26:43 2008
@@ -3740,6 +3740,26 @@
a = """class m(a, arg=23, metaclass=Meta): pass"""
self.check(b, a)
+ b = """
+ class X(expression(2 + 4)):
+ __metaclass__ = Meta
+ """
+ a = """
+ class X(expression(2 + 4), metaclass=Meta):
+ pass
+ """
+ self.check(b, a)
+
+ b = """
+ class X(expression(2 + 4), x**4):
+ __metaclass__ = Meta
+ """
+ a = """
+ class X(expression(2 + 4), x**4, metaclass=Meta):
+ pass
+ """
+ self.check(b, a)
+
class Test_getcwdu(FixerTestCase):
More information about the Python-checkins
mailing list