1.1 --- a/micropython/__init__.py Fri Jun 28 17:18:03 2013 +0200
1.2 +++ b/micropython/__init__.py Fri Jun 28 21:17:02 2013 +0200
1.3 @@ -5,7 +5,7 @@
1.4 from the simplify package but has had various details related to that package
1.5 removed.
1.6
1.7 -Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -456,6 +456,7 @@
1.13
1.14 self.attribute_users_visited = set()
1.15 self.attributes_to_visit = {}
1.16 + self.attribute_users_seen = 0
1.17
1.18 # Attribute usage type deduction failures.
1.19
1.20 @@ -672,7 +673,8 @@
1.21 types.
1.22 """
1.23
1.24 - if from_name != "__builtins__.getattr" and from_name in self.attribute_users_visited:
1.25 + if from_name != "__builtins__.getattr" and from_name in self.attribute_users_visited or \
1.26 + from_name == "__builtins__.getattr" and len(self.attribute_users_visited) == self.attribute_users_seen:
1.27 return
1.28
1.29 self.attribute_users_visited.add(from_name)
1.30 @@ -688,6 +690,11 @@
1.31 # to build a set of objects that might be referenced by getattr.
1.32
1.33 if from_name == "__builtins__.getattr":
1.34 +
1.35 + # Note the number of attribute users visited at this point.
1.36 +
1.37 + self.attribute_users_seen = len(self.attribute_users_visited)
1.38 +
1.39 all_attributes = set(objtable.attribute_names())
1.40 all_string_constants = set([const.get_value() for const in self.constants() if const.value_type_name() == "__builtins__.str"])
1.41 all_attribute_constants = all_attributes.intersection(all_string_constants)