[Python-projects] astng crashes on yield expression

Huurne, Maarten ter maarten.ter.huurne at philips.com
Thu Mar 26 20:08:05 CET 2009


Hi,

I found a workaround that avoids crashes on yield expressions and does not cause false positives on yield statements:
===
diff -ru logilab-astng-0.19.0.org/nodes.py logilab-astng-0.19.0/nodes.py
--- logilab-astng-0.19.0.org/nodes.py   2009-03-26 19:57:42.000000000 +0100
+++ logilab-astng-0.19.0/nodes.py       2009-03-26 19:57:57.000000000 +0100
@@ -248,7 +248,10 @@
             return
         while not (self.is_statement or isinstance(self, Module)):
             self = self.parent
-        stmts = self.parent.child_sequence(self)
+        field_, stmts = self.parent.locate_child(self)
+        if stmts is self:
+            self = self.parent
+            stmts = self.parent.child_sequence(self)
         index = stmts.index(self)
         if index >= 1:
             return stmts[index -1]
===

This workaround lacks elegance and next_statement() most likely still has the potential to crash, so I wouldn't call it a solution.

Bye,
                                Maarten


________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.logilab.org/pipermail/python-projects/attachments/20090326/4b0e121b/attachment-0001.htm>


More information about the Python-Projects mailing list