1.1 --- a/micropython/report.py Sun Jul 08 02:26:27 2012 +0200
1.2 +++ b/micropython/report.py Sun Jul 08 19:21:56 2012 +0200
1.3 @@ -370,7 +370,18 @@
1.4
1.5 def _attribute_start(self, attrname, attributes):
1.6 if attributes:
1.7 - attributes.sort(key=lambda t: t[2])
1.8 +
1.9 + # Get the output form of the attributes.
1.10 +
1.11 + output = []
1.12 + for value, target, target_name in attributes:
1.13 + if value and not isinstance(value, Instance):
1.14 + fullname = value.full_name()
1.15 + else:
1.16 + fullname = target_name + "." + attrname
1.17 + output.append((fullname, value))
1.18 +
1.19 + output.sort()
1.20
1.21 self._span_start("attr")
1.22 self._popup_start("attributes-popup")
1.23 @@ -380,22 +391,15 @@
1.24 # attributes.
1.25
1.26 last = None
1.27 - for value, target, target_name in attributes:
1.28 - if value and not isinstance(value, Instance):
1.29 - fullname = value.full_name()
1.30 - current = (value, fullname)
1.31 - if current != last:
1.32 - if last is not None:
1.33 - self.stream.write("<br />")
1.34 + for fullname, value in output:
1.35 + if fullname != last:
1.36 + if last is not None:
1.37 + self.stream.write("<br />")
1.38 + if value is not None and not isinstance(value, Instance):
1.39 self._object_name_ref(value.module, value, fullname, classes="attribute-name")
1.40 - else:
1.41 - fullname = target_name + "." + attrname
1.42 - current = (None, fullname)
1.43 - if current != last:
1.44 - if last is not None:
1.45 - self.stream.write("<br />")
1.46 + else:
1.47 self.stream.write(fullname)
1.48 - last = current
1.49 + last = fullname
1.50
1.51 self._names_list_end()
1.52 self._popup_end()
1.53 @@ -984,8 +988,8 @@
1.54
1.55 def visitAssAttr(self, node):
1.56 possible_types = self.possible_accessor_types(node, defining_users=0)
1.57 - target_names = ["%s%s" % (is_static and "static " or "", target_name)
1.58 - for target_name, is_static in possible_types]
1.59 + target_names = set(["%s%s" % (is_static and "static " or "", target_name)
1.60 + for target_name, is_static in possible_types])
1.61 attributes = self._get_attributes(possible_types, node.attrname)
1.62
1.63 wraps_getattr = isinstance(node.expr, compiler.ast.Getattr)
1.64 @@ -1084,8 +1088,8 @@
1.65
1.66 def visitGetattr(self, node):
1.67 possible_types = self.possible_accessor_types(node, defining_users=0)
1.68 - target_names = ["%s%s" % (is_static and "static " or "", target_name)
1.69 - for target_name, is_static in possible_types]
1.70 + target_names = set(["%s%s" % (is_static and "static " or "", target_name)
1.71 + for target_name, is_static in possible_types])
1.72 attributes = self._get_attributes(possible_types, node.attrname)
1.73
1.74 wraps_getattr = isinstance(node.expr, compiler.ast.Getattr)