# HG changeset patch # User Paul Boddie # Date 1341270963 -7200 # Node ID bd9b6f1968163b3fc83827269c9e71850f7faa44 # Parent f2ee197956f746a5b272c105a70f288a4d4796ee Reverted changes to global attribute usage handling in anticipation of "usage revocation" support, where observations are discarded upon detecting that a module may be modified during initialisation. diff -r f2ee197956f7 -r bd9b6f196816 docs/annotations.txt --- a/docs/annotations.txt Mon Jul 02 00:58:10 2012 +0200 +++ b/docs/annotations.txt Tue Jul 03 01:16:03 2012 +0200 @@ -12,20 +12,24 @@ Attribute Users --------------- -_attrnames defines a dictionary mapping local names to sets of - attribute names found to be used with those names in a - branch _attrcontributors defines nodes contributing to combined attribute usage known to a node _attrcombined defines a dictionary mapping local names to sets of attribute names found to be used with those names for the entire lifetime of a particular attribute user +_attrtypes defines types deduced either from combined attribute usage + details (for users) + +Attribute Contributors +---------------------- + +_attrnames defines a dictionary mapping local names to sets of + attribute names found to be used with those names in a + branch _attrmerged defines a dictionary mapping local names to sets of attribute names merging combined observations with locally applicable observations, indicating usage specific to a region of the code -_attrtypes defines types deduced either from combined attribute usage - details (for users) _attrspecifictypes defines specific types from merged attribute usage details (for non-user nodes) _attrdefs defines definition-related users which consume usage details diff -r f2ee197956f7 -r bd9b6f196816 micropython/data.py --- a/micropython/data.py Mon Jul 02 00:58:10 2012 +0200 +++ b/micropython/data.py Tue Jul 03 01:16:03 2012 +0200 @@ -2055,26 +2055,6 @@ return dict(self) - # Attribute usage methods that do not apply to module globals. - - def _define_attribute_user(self, node): - pass - - def _use_attribute(self, name, attrname, value=None): - - """ - Record usage for 'name' of 'attrname' (and optional assignment 'value') - by recording general name usage. - """ - - self.importer.use_name(attrname, self.full_name(), value) - - def _init_attribute_user(self, node): - pass - - def _define_attribute_accessor(self, name, attrname, node, value): - pass - # Pre-made instances. type_class = TypeClass("type") # details to be filled in later diff -r f2ee197956f7 -r bd9b6f196816 micropython/inspect.py --- a/micropython/inspect.py Mon Jul 02 00:58:10 2012 +0200 +++ b/micropython/inspect.py Tue Jul 03 01:16:03 2012 +0200 @@ -598,12 +598,12 @@ where such attributes are inferred from the usage. """ - # Access to attributes via a local in functions or classes but not - # modules (since module-level locals are globals that can be modified - # independently of the namespace), or access via a module global within - # a function. + # Access to attributes via a local in functions, classes or modules. + # Since module-level locals are globals that can be modified + # independently of the namespace, any attribute usage observations made + # here may be revoked later if such modification is thought to occur. - if expr.parent is self.get_namespace() and not self.get_namespace() is self: + if expr.parent is self.get_namespace(): self.define_attribute_accessor(expr.name, attrname, node, value) else: self.use_name(attrname, node.expr, value, ns=expr.parent)