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!
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)
> Best regards,
> Winfried
--
Emile Anclin <[email protected]>
http://www.logilab.fr/ http://www.logilab.org/
Informatique scientifique & et gestion de connaissances
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects