# HG changeset patch # User Paul Boddie # Date 1382831647 -7200 # Node ID f65236401d4ed57240ae6db0dd680a00f7a0ddd3 # Parent dead7756e3d60a745a9f5177ac1259b385310955 Separated the acquisition of local attributes from general namespace access. diff -r dead7756e3d6 -r f65236401d4e micropython/data.py --- a/micropython/data.py Sun Oct 27 01:51:49 2013 +0200 +++ b/micropython/data.py Sun Oct 27 01:54:07 2013 +0200 @@ -174,6 +174,24 @@ return attr + def get_for_local(self, name): + + """ + Get an attribute for a local name annotation, maintaining specific + assignment information. + """ + + attr, scope, full_name = self._get_with_scope(name) + + if scope != "local": + return None + + users = self.attribute_users[-1] + if users.has_key(name): + return LocalAttr(None, self, name, nodes=users[name]) + else: + return attr + def _get_with_scope(self, name, external=0): """ @@ -188,7 +206,6 @@ module = self.module builtins = module and module.builtins or None importer = module and module.importer or None - users = self.attribute_users[-1] # Constants. @@ -197,9 +214,6 @@ # Locals. - elif not external and users.has_key(name): - return LocalAttr(None, self, name, nodes=users[name]), "local", self.full_name() - elif not external and self.has_key(name): return self[name], "local", self.full_name() diff -r dead7756e3d6 -r f65236401d4e micropython/inspect.py --- a/micropython/inspect.py Sun Oct 27 01:51:49 2013 +0200 +++ b/micropython/inspect.py Sun Oct 27 01:54:07 2013 +0200 @@ -1378,7 +1378,7 @@ def visitName(self, node): attr = self.get_namespace().get_using_node(node.name, node) or make_instance() - node._attr = attr + node._attr = self.get_namespace().get_for_local(node.name) or make_instance() return attr def visitNot(self, node):