summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/pycodegen.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-03-19 17:56:01 (GMT)
committerGuido van Rossum <guido@python.org>2007-03-19 17:56:01 (GMT)
commitd16e81aabe5448a90640694d57cdaefddf3a1a9f (patch)
tree1d422ec1ee0944f60ceedd91f69af4034cb170e6 /Lib/compiler/pycodegen.py
parent801dd736531f7d6db57a1dab80fe6daa37e0a0b0 (diff)
downloadcpython-d16e81aabe5448a90640694d57cdaefddf3a1a9f.zip
cpython-d16e81aabe5448a90640694d57cdaefddf3a1a9f.tar.gz
cpython-d16e81aabe5448a90640694d57cdaefddf3a1a9f.tar.bz2
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.
Diffstat (limited to 'Lib/compiler/pycodegen.py')
-rw-r--r--Lib/compiler/pycodegen.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index 83fbc17..cc24650 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):