# HG changeset patch # User Paul Boddie # Date 1351812867 -3600 # Node ID 69bb1e2b79a5f4593e4d1c35ade839fbe1785f2d # Parent fd8af882bf7e1ccc01de3a58b1cc5efe5238e3bd Replaced get_static_attribute methods with all_attributes methods that provide access to all attributes available on a class or module. Fixed the possible_accessor_types method to not record empty target sets where no concrete attributes can be found. diff -r fd8af882bf7e -r 69bb1e2b79a5 micropython/basicdata.py --- a/micropython/basicdata.py Mon Oct 29 22:27:15 2012 +0100 +++ b/micropython/basicdata.py Fri Nov 02 00:34:27 2012 +0100 @@ -39,18 +39,20 @@ else: return self.parent.full_name() +no_attributes = {} + class Namespace: "A mix-in providing basic namespace functionality." - def get_static_attribute(self, name): + def all_attributes(self): """ - Return a static attribute for the given 'name' or None if no such - attribute exists. + Return all attributes accessible through a namespace, whether provided + directly by the namespace or by other mechanisms. """ - return None + return no_attributes class Constant: diff -r fd8af882bf7e -r 69bb1e2b79a5 micropython/common.py --- a/micropython/common.py Mon Oct 29 22:27:15 2012 +0100 +++ b/micropython/common.py Fri Nov 02 00:34:27 2012 +0100 @@ -106,8 +106,14 @@ if exprs: target_names = set() + # For each expression value try and get a concrete + # attribute. + for expr in exprs: - attr = expr.get_static_attribute(node.attrname) + attr = expr.all_attributes().get(node.attrname) + + # Where an attribute can be obtained, record its + # details. if attr: target_names.add((attr.parent.full_name(), attr.is_static_attribute())) @@ -135,11 +141,13 @@ for target_name, is_static in user._attrspecifictypes.get(node._username, []): target_names.add((target_name, is_static)) - all_target_names.append(target_names) + if target_names: + all_target_names.append(target_names) # Return the smallest set of target names. all_target_names.sort(key=lambda x: len(x)) + return all_target_names and all_target_names[0] def used_by_unit(node): diff -r fd8af882bf7e -r 69bb1e2b79a5 micropython/data.py --- a/micropython/data.py Mon Oct 29 22:27:15 2012 +0100 +++ b/micropython/data.py Fri Nov 02 00:34:27 2012 +0100 @@ -1656,15 +1656,6 @@ self.allattr[name] = attr return self.allattr - def get_static_attribute(self, name): - - """ - Return a static attribute for the given 'name' or None if no such - attribute exists. - """ - - return self.all_class_attributes().get(name) - class TypeClass(Class): "A special class for the type class." @@ -2089,6 +2080,8 @@ return dict(self) + all_attributes = module_attributes + def get_static_attribute(self, name): """