1.1 --- a/micropython/common.py Sun Jul 01 01:04:07 2012 +0200
1.2 +++ b/micropython/common.py Sun Jul 01 01:53:28 2012 +0200
1.3 @@ -19,7 +19,7 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from micropython.data import Attr, Instance
1.8 +from micropython.data import Attr, Instance, UnresolvedName
1.9 from micropython.errors import *
1.10 import sys
1.11
1.12 @@ -70,7 +70,7 @@
1.13
1.14 target_names = set()
1.15
1.16 - if hasattr(node, "_attr") and not isinstance(node._attr, Instance):
1.17 + if hasattr(node, "_attr") and not isinstance(node._attr, (Instance, UnresolvedName)):
1.18 attr = node._attr
1.19 if isinstance(attr, Attr):
1.20 target_names.add((attr.parent.full_name(), attr.is_static_attribute()))
2.1 --- a/micropython/report.py Sun Jul 01 01:04:07 2012 +0200
2.2 +++ b/micropython/report.py Sun Jul 01 01:53:28 2012 +0200
2.3 @@ -23,6 +23,7 @@
2.4 from micropython.data import *
2.5 from micropython.errors import *
2.6 from os.path import exists, extsep, join
2.7 +import compiler.ast
2.8 import sys
2.9 import os
2.10 import textwrap
2.11 @@ -987,15 +988,20 @@
2.12 for target_name, is_static in possible_types]
2.13 attributes = self._get_attributes(possible_types, node.attrname)
2.14
2.15 - self._span_start("assattr")
2.16 - self._accessor_start(target_names)
2.17 + wraps_getattr = isinstance(node.expr, compiler.ast.Getattr)
2.18 +
2.19 + if not wraps_getattr:
2.20 + self._span_start("assattr")
2.21 + self._accessor_start(target_names)
2.22 self.dispatch(node.expr)
2.23 - self._accessor_end(target_names)
2.24 + if not wraps_getattr:
2.25 + self._accessor_end(target_names)
2.26 self.stream.write(".")
2.27 self._attribute_start(node.attrname, attributes)
2.28 self._span(node.attrname, "attrname" + (not target_names and " no-targets" or ""))
2.29 self._attribute_end(attributes)
2.30 - self._span_end()
2.31 + if not wraps_getattr:
2.32 + self._span_end()
2.33
2.34 def visitAssList(self, node):
2.35 self._span_start("list")
2.36 @@ -1082,15 +1088,20 @@
2.37 for target_name, is_static in possible_types]
2.38 attributes = self._get_attributes(possible_types, node.attrname)
2.39
2.40 - self._span_start("getattr")
2.41 - self._accessor_start(target_names)
2.42 + wraps_getattr = isinstance(node.expr, compiler.ast.Getattr)
2.43 +
2.44 + if not wraps_getattr:
2.45 + self._span_start("getattr")
2.46 + self._accessor_start(target_names)
2.47 self.dispatch(node.expr)
2.48 - self._accessor_end(target_names)
2.49 + if not wraps_getattr:
2.50 + self._accessor_end(target_names)
2.51 self.stream.write(".")
2.52 self._attribute_start(node.attrname, attributes)
2.53 self._span(node.attrname, "attrname" + (not target_names and " no-targets" or ""))
2.54 self._attribute_end(attributes)
2.55 - self._span_end()
2.56 + if not wraps_getattr:
2.57 + self._span_end()
2.58
2.59 def visitGenExpr(self, node):
2.60 self._span_start("genexpr")