1.1 --- a/micropython/common.py Sun Jul 08 02:26:27 2012 +0200
1.2 +++ b/micropython/common.py Sun Jul 08 19:21:56 2012 +0200
1.3 @@ -23,6 +23,11 @@
1.4 from micropython.errors import *
1.5 import sys
1.6
1.7 +try:
1.8 + set
1.9 +except NameError:
1.10 + from sets import Set as set
1.11 +
1.12 # Visitors and activities related to node annotations.
1.13
1.14 class ASTVisitor:
2.1 --- a/micropython/program.py Sun Jul 08 02:26:27 2012 +0200
2.2 +++ b/micropython/program.py Sun Jul 08 19:21:56 2012 +0200
2.3 @@ -19,6 +19,11 @@
2.4 this program. If not, see <http://www.gnu.org/licenses/>.
2.5 """
2.6
2.7 +try:
2.8 + set
2.9 +except NameError:
2.10 + from sets import Set as set
2.11 +
2.12 class Location:
2.13
2.14 """
3.1 --- a/micropython/report.py Sun Jul 08 02:26:27 2012 +0200
3.2 +++ b/micropython/report.py Sun Jul 08 19:21:56 2012 +0200
3.3 @@ -370,7 +370,18 @@
3.4
3.5 def _attribute_start(self, attrname, attributes):
3.6 if attributes:
3.7 - attributes.sort(key=lambda t: t[2])
3.8 +
3.9 + # Get the output form of the attributes.
3.10 +
3.11 + output = []
3.12 + for value, target, target_name in attributes:
3.13 + if value and not isinstance(value, Instance):
3.14 + fullname = value.full_name()
3.15 + else:
3.16 + fullname = target_name + "." + attrname
3.17 + output.append((fullname, value))
3.18 +
3.19 + output.sort()
3.20
3.21 self._span_start("attr")
3.22 self._popup_start("attributes-popup")
3.23 @@ -380,22 +391,15 @@
3.24 # attributes.
3.25
3.26 last = None
3.27 - for value, target, target_name in attributes:
3.28 - if value and not isinstance(value, Instance):
3.29 - fullname = value.full_name()
3.30 - current = (value, fullname)
3.31 - if current != last:
3.32 - if last is not None:
3.33 - self.stream.write("<br />")
3.34 + for fullname, value in output:
3.35 + if fullname != last:
3.36 + if last is not None:
3.37 + self.stream.write("<br />")
3.38 + if value is not None and not isinstance(value, Instance):
3.39 self._object_name_ref(value.module, value, fullname, classes="attribute-name")
3.40 - else:
3.41 - fullname = target_name + "." + attrname
3.42 - current = (None, fullname)
3.43 - if current != last:
3.44 - if last is not None:
3.45 - self.stream.write("<br />")
3.46 + else:
3.47 self.stream.write(fullname)
3.48 - last = current
3.49 + last = fullname
3.50
3.51 self._names_list_end()
3.52 self._popup_end()
3.53 @@ -984,8 +988,8 @@
3.54
3.55 def visitAssAttr(self, node):
3.56 possible_types = self.possible_accessor_types(node, defining_users=0)
3.57 - target_names = ["%s%s" % (is_static and "static " or "", target_name)
3.58 - for target_name, is_static in possible_types]
3.59 + target_names = set(["%s%s" % (is_static and "static " or "", target_name)
3.60 + for target_name, is_static in possible_types])
3.61 attributes = self._get_attributes(possible_types, node.attrname)
3.62
3.63 wraps_getattr = isinstance(node.expr, compiler.ast.Getattr)
3.64 @@ -1084,8 +1088,8 @@
3.65
3.66 def visitGetattr(self, node):
3.67 possible_types = self.possible_accessor_types(node, defining_users=0)
3.68 - target_names = ["%s%s" % (is_static and "static " or "", target_name)
3.69 - for target_name, is_static in possible_types]
3.70 + target_names = set(["%s%s" % (is_static and "static " or "", target_name)
3.71 + for target_name, is_static in possible_types])
3.72 attributes = self._get_attributes(possible_types, node.attrname)
3.73
3.74 wraps_getattr = isinstance(node.expr, compiler.ast.Getattr)