diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-11-10 22:21:33 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-11-10 22:21:33 (GMT) |
commit | ba55818a3a0b96192fe9a43d13912baa58306ab0 (patch) | |
tree | f518dc6dc83c76b037b93252ff5b8d2bbbb94753 /Lib/lib2to3/fixes/fix_metaclass.py | |
parent | 065ba709e8caf3cab936f22ad9782c2cf970b38f (diff) | |
download | cpython-ba55818a3a0b96192fe9a43d13912baa58306ab0.zip cpython-ba55818a3a0b96192fe9a43d13912baa58306ab0.tar.gz cpython-ba55818a3a0b96192fe9a43d13912baa58306ab0.tar.bz2 |
Merged revisions 67180 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67180 | benjamin.peterson | 2008-11-10 16:11:12 -0600 (Mon, 10 Nov 2008) | 29 lines
Merged revisions 66985,67170,67173,67177-67179 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r66985 | benjamin.peterson | 2008-10-20 16:43:46 -0500 (Mon, 20 Oct 2008) | 1 line
no need to use nested try, except, finally
........
r67170 | benjamin.peterson | 2008-11-08 12:28:31 -0600 (Sat, 08 Nov 2008) | 1 line
fix #4271: fix_imports didn't recognize imports with parenthesis (ie from x import (a, b))
........
r67173 | benjamin.peterson | 2008-11-08 17:42:08 -0600 (Sat, 08 Nov 2008) | 1 line
consolidate test
........
r67177 | benjamin.peterson | 2008-11-09 21:52:52 -0600 (Sun, 09 Nov 2008) | 1 line
let the metclass fixer handle complex assignments in the class body gracefully
........
r67178 | benjamin.peterson | 2008-11-10 15:26:43 -0600 (Mon, 10 Nov 2008) | 1 line
the metaclass fixers shouldn't die when bases are not a simple name
........
r67179 | benjamin.peterson | 2008-11-10 15:29:58 -0600 (Mon, 10 Nov 2008) | 1 line
allow the fix_import pattern to catch from imports with parenthesis
........
................
Diffstat (limited to 'Lib/lib2to3/fixes/fix_metaclass.py')
-rw-r--r-- | Lib/lib2to3/fixes/fix_metaclass.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/lib2to3/fixes/fix_metaclass.py b/Lib/lib2to3/fixes/fix_metaclass.py index 7479024..c2f4b7f 100644 --- a/Lib/lib2to3/fixes/fix_metaclass.py +++ b/Lib/lib2to3/fixes/fix_metaclass.py @@ -35,8 +35,9 @@ def has_metaclass(parent): 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 @@ -165,12 +166,10 @@ class FixMetaclass(fixer_base.BaseFix): 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 |