Permalink
Browse files

Factor out gen.Start_() method.

I called it Start_() instead of Start() because otherwise compilation of
benchmarks/pytrace() changes!

It has a Start() method in it.  The names of the variables in the
compiler's implementation leak through to the output bytecode!
  • Loading branch information...
Andy Chu
Andy Chu committed Mar 19, 2018
1 parent dff26dc commit 888f52c16a5608721af80289622f681849e0c7af
Showing with 5 additions and 0 deletions.
  1. +5 −0 opy/compiler2/pycodegen.py
@@ -328,6 +328,7 @@ def _visitFuncOrLambda(self, node, isLambda=0):
gen = FunctionCodeGenerator(node, self.scopes, isLambda,
self.class_name, self.get_module())
gen.Start_()
gen.FindLocals()
walk(node.code, gen)
gen.Finish()
@@ -622,6 +623,7 @@ def _makeClosure(self, gen, args):
def visitGenExpr(self, node):
gen = GenExprCodeGenerator(node, self.scopes, self.class_name,
self.get_module())
gen.Start_()
gen.FindLocals()
walk(node.code, gen)
gen.Finish()
@@ -1345,6 +1347,8 @@ def __init__(self, func, scopes, isLambda, class_name, mod):
obj_name = func.name
FunctionMixin.__init__(self, func, obj_name, isLambda, class_name, mod)
def Start_(self):
self.graph.setFreeVars(self.scope.get_free_vars())
self.graph.setCellVars(self.scope.get_cell_vars())
if self.scope.generator is not None:
@@ -1374,6 +1378,7 @@ def __init__(self, gexp, scopes, class_name, mod):
isLambda = 1
FunctionMixin.__init__(self, gexp, obj_name, isLambda, class_name, mod)
def Start_(self):
self.graph.setFreeVars(self.scope.get_free_vars())
self.graph.setCellVars(self.scope.get_cell_vars())
self.graph.setFlag(CO_GENERATOR)

0 comments on commit 888f52c

Please sign in to comment.