On 13 janvier 16:08, Emile Anclin wrote: > On Tuesday 12 January 2010 15:56:37 Winfried Plappert wrote: > > Hi there, > > hi, > > > I found a bug in above module, for method visit_ifexp: > > > > Original > > (logilab_astng-0.19.3-py2.6.egg/logilab/astng/nodes_as_string.py): > > (line 241) > > > > def visit_ifexp(self, node): > > """return an astng.IfExp node as string""" > > ifs = ['%s if %s' % (self._stmt_list(node.body), > > node.test.accept(self))] > > if node.orelse: > > ifs.append('else %s' % self._stmt_list(node.orelse)) > > return ' '.join(ifs) > > > > My fix: > > def visit_ifexp(self, node): > > """return an astng.IfExp node as string""" > > return '%s if %s else %s' % (node.body.accept(self), > > node.test.accept(self), node.orelse.accept(self)) > > > > Since we deal here with arithmetic expressions for node.body and > > node.orelse they must be 'accepted'.I think the code has been copied > > from vist_if and was not modified afterwards. > > thanks a lot!
checked in astng stable branch. > by the way, there is another bug in this part of the code, > concerning visit_unaryop : > > def visit_unaryop(self, node): > """return an astng.UnaryOp node as string""" > - return '%s%s' % (node.op, node.operand.accept(self)) > + # parenthesis: at least to protect 'not' to avoid 'notX' for 'not > X' > + return '%s(%s)' % (node.op, node.operand.accept(self)) > > (I fixed this in my refactoring branch) I would prefer to special case 'not' to get prettier printing. -- Sylvain Thénault LOGILAB, Paris (France) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework: http://www.cubicweb.org _______________________________________________ Python-Projects mailing list Python-Projects@lists.logilab.org http://lists.logilab.org/mailman/listinfo/python-projects