From d16e81aabe5448a90640694d57cdaefddf3a1a9f Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 19 Mar 2007 17:56:01 +0000 Subject: Fix the compiler package w.r.t. the new metaclass syntax. (It is still broken w.r.t. the new nonlocal keyword.) Remove a series of debug prints I accidentally left in test_ast.py. --- Lib/compiler/pycodegen.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'Lib/compiler/pycodegen.py') diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index 83fbc173ca..cc24650cfd 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/compiler/pycodegen.py @@ -435,13 +435,10 @@ class CodeGenerator: walk(node.code, gen) gen.finish() self.set_lineno(node) - self.emit('LOAD_CONST', node.name) - for base in node.bases: - self.visit(base) - self.emit('BUILD_TUPLE', len(node.bases)) + self.emit('LOAD_BUILD_CLASS') self._makeClosure(gen, 0) - self.emit('CALL_FUNCTION', 0) - self.emit('BUILD_CLASS') + self.emit('LOAD_CONST', node.name) + self.finish_visit_call(node, 2) self.storeName(node.name) # The rest are standard visitor methods @@ -1115,10 +1112,11 @@ class CodeGenerator: self.emit('STORE_SUBSCR') def visitCallFunc(self, node): - pos = 0 - kw = 0 self.set_lineno(node) self.visit(node.node) + self.finish_visit_call(node) + + def finish_visit_call(self, node, pos=0, kw=0): for arg in node.args: self.visit(arg) if isinstance(arg, ast.Keyword): @@ -1467,7 +1465,7 @@ class AbstractClassCode: def finish(self): self.graph.startExitBlock() - self.emit('LOAD_LOCALS') + self.emit('LOAD_CONST', None) self.emit('RETURN_VALUE') class ClassCodeGenerator(NestedScopeMixin, AbstractClassCode, CodeGenerator): -- cgit v1.2.1