# HG changeset patch # User Paul Boddie # Date 1372447022 -7200 # Node ID 979e2a19fc4a1998330b613090aa093b04101170 # Parent 554da4ac46aa5106d85aaeca6b426a96fb213730 Introduced a termination case where no new dynamic attribute knowledge is available. diff -r 554da4ac46aa -r 979e2a19fc4a micropython/__init__.py --- a/micropython/__init__.py Fri Jun 28 17:18:03 2013 +0200 +++ b/micropython/__init__.py Fri Jun 28 21:17:02 2013 +0200 @@ -5,7 +5,7 @@ from the simplify package but has had various details related to that package removed. -Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Paul Boddie +Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -456,6 +456,7 @@ self.attribute_users_visited = set() self.attributes_to_visit = {} + self.attribute_users_seen = 0 # Attribute usage type deduction failures. @@ -672,7 +673,8 @@ types. """ - if from_name != "__builtins__.getattr" and from_name in self.attribute_users_visited: + if from_name != "__builtins__.getattr" and from_name in self.attribute_users_visited or \ + from_name == "__builtins__.getattr" and len(self.attribute_users_visited) == self.attribute_users_seen: return self.attribute_users_visited.add(from_name) @@ -688,6 +690,11 @@ # to build a set of objects that might be referenced by getattr. if from_name == "__builtins__.getattr": + + # Note the number of attribute users visited at this point. + + self.attribute_users_seen = len(self.attribute_users_visited) + all_attributes = set(objtable.attribute_names()) all_string_constants = set([const.get_value() for const in self.constants() if const.value_type_name() == "__builtins__.str"]) all_attribute_constants = all_attributes.intersection(all_string_constants)