# HG changeset patch # User Paul Boddie # Date 1269562622 -3600 # Node ID 24ac217a0e3009d7de93c401de7d7fa83d4aec1e # Parent 02757ef74c891afa6540d504e1454a3047db3f99 Fixed errors when overspecific attribute usage caused the removal of attributes, even though the effect should only be the non-enforcement of guards and less filtering of attributes and program sections. diff -r 02757ef74c89 -r 24ac217a0e30 TO_DO.txt --- a/TO_DO.txt Sun Mar 07 02:21:18 2010 +0100 +++ b/TO_DO.txt Fri Mar 26 01:17:02 2010 +0100 @@ -1,3 +1,9 @@ +Where attribute combinations do not yield objects +(tests/abandoned_attribute_usage_multiple_candidates.py) in +Importer._collect_attributes, the individual attributes should be exposed, +since it is apparent that no single object type can satisfy the reported +combination, and thus a guard will not be generated. + Loop entry points should capture usage to update later assignments in the loop. The continue and break statements should affect usage propagation. diff -r 02757ef74c89 -r 24ac217a0e30 micropython/__init__.py --- a/micropython/__init__.py Sun Mar 07 02:21:18 2010 +0100 +++ b/micropython/__init__.py Fri Mar 26 01:17:02 2010 +0100 @@ -518,7 +518,14 @@ # combinations of attribute names. for names in self.name_references.get(from_name, []): - for objname in objtable.all_possible_objects(names): + objnames = objtable.all_possible_objects(names) + if not objnames: + print "Warning: usage in %r finds no object supporting all attributes %r" % (from_name, names) + objnames = objtable.any_possible_objects(names) + if not objnames: + print "Warning: usage in %r finds no object supporting any attributes %r" % (from_name, names) + + for objname in objnames: for name in names: self.use_attribute(objname, name) self._collect_attributes(objname + "." + name, objtable) diff -r 02757ef74c89 -r 24ac217a0e30 micropython/table.py --- a/micropython/table.py Sun Mar 07 02:21:18 2010 +0100 +++ b/micropython/table.py Fri Mar 26 01:17:02 2010 +0100 @@ -310,6 +310,23 @@ possible.append(objname) return possible + def any_possible_objects(self, names): + + """ + Return a list of object names supporting any of the given attribute 'names'. + """ + + possible = [] + for objname, attributes in self.table.items(): + found = 0 + for name in names: + if attributes.has_key(name): + found = 1 + break + if found: + possible.append(objname) + return possible + def as_list(self): """