# HG changeset patch # User Paul Boddie # Date 1351815368 -3600 # Node ID 327b862e58b67812681ee6746c9468adcda2613a # Parent 5d7a60729f293534e9df98371e0182919733c456 Improved tests for Getattr nodes within others, thus avoiding competing pop-ups. diff -r 5d7a60729f29 -r 327b862e58b6 micropython/report.py --- a/micropython/report.py Fri Nov 02 00:58:26 2012 +0100 +++ b/micropython/report.py Fri Nov 02 01:16:08 2012 +0100 @@ -1041,7 +1041,7 @@ possible_types = self.possible_accessor_types(node, defining_users=0) attributes = self._get_attributes(possible_types, node.attrname) - wraps_getattr = isinstance(node.expr, compiler.ast.Getattr) + wraps_getattr = self._has_descendant(node.expr, compiler.ast.Getattr) if not wraps_getattr: self._span_start("assattr") @@ -1139,7 +1139,7 @@ possible_types = self.possible_accessor_types(node, defining_users=0) attributes = self._get_attributes(possible_types, node.attrname) - wraps_getattr = isinstance(node.expr, compiler.ast.Getattr) + wraps_getattr = self._has_descendant(node.expr, compiler.ast.Getattr) if not wraps_getattr: self._span_start("getattr") @@ -1436,6 +1436,17 @@ self.program.unknown_target_nodes.append((self.units[-1], node)) return possible_types + # Utility methods. + + def _has_descendant(self, node, nodetype): + if isinstance(node, nodetype): + return True + else: + for n in node.getChildNodes(): + if self._has_descendant(n, nodetype): + return True + return False + # Convenience functions. def summarise(module, program, filename):