My favorites | Sign in
Project Logo
epy
             
Details: Show all Hide all

Earlier this year

  • May 26, 2009
    issue 13 (operator multiple operands) reported by dimonb   -   What steps will reproduce the problem? 1. python code 1+2+4 converted to javascript 3 What is the expected output? What do you see instead? expected 7 Please provide any additional information below. this patch should help: --- _visitor.py (revision 7807) +++ _visitor.py (working copy) @@ -104,15 +104,15 @@ def opBase(self,t,op): args = t.getChildNodes() - lnode, rnode = [self.epy.parseNode(arg) for arg in args[:2]] + nodes = [self.epy.parseNode(arg) for arg in args] if all([isinstance(arg, compiler.ast.Const) for arg in args]): # Optimize constants be pre-evaluating const-const expressions - result = eval(lnode + op + rnode) + result = eval(op.join(nodes)) if isinstance(result, str): result = "\"%s\"" % result self.src += "(%s)" % str(result) else: - self.src += "(%s %s %s)" % (lnode, op, rnode) + self.src += "(%s)" % op.join(nodes) def visitOr(self,t): self.opBase(t, "||")
    What steps will reproduce the problem? 1. python code 1+2+4 converted to javascript 3 What is the expected output? What do you see instead? expected 7 Please provide any additional information below. this patch should help: --- _visitor.py (revision 7807) +++ _visitor.py (working copy) @@ -104,15 +104,15 @@ def opBase(self,t,op): args = t.getChildNodes() - lnode, rnode = [self.epy.parseNode(arg) for arg in args[:2]] + nodes = [self.epy.parseNode(arg) for arg in args] if all([isinstance(arg, compiler.ast.Const) for arg in args]): # Optimize constants be pre-evaluating const-const expressions - result = eval(lnode + op + rnode) + result = eval(op.join(nodes)) if isinstance(result, str): result = "\"%s\"" % result self.src += "(%s)" % str(result) else: - self.src += "(%s %s %s)" % (lnode, op, rnode) + self.src += "(%s)" % op.join(nodes) def visitOr(self,t): self.opBase(t, "||")

Older

 
Hosted by Google Code