1.1 --- a/micropython/data.py Fri Jun 29 01:44:08 2012 +0200
1.2 +++ b/micropython/data.py Sat Jun 30 00:02:31 2012 +0200
1.3 @@ -613,24 +613,26 @@
1.4
1.5 users = self.attribute_users[-1]
1.6
1.7 + # If no users are defined for the name, provide the current namespace.
1.8 +
1.9 + if not users.has_key(name):
1.10 + self._define_attribute_user_for_name(self.astnode, name)
1.11 +
1.12 # Add the usage to all current users.
1.13
1.14 - if users.has_key(name):
1.15 - for user in users[name]:
1.16 - values = user._attrnames[name]
1.17 - if values is None:
1.18 - values = user._attrnames[name] = ObjectSet()
1.19 -
1.20 - # Add an entry for the attribute, optionally with an assigned
1.21 - # value.
1.22 -
1.23 - values.add(attrname)
1.24 - if value is not None:
1.25 - values[attrname].add(value)
1.26 -
1.27 - return users[name]
1.28 - else:
1.29 - return []
1.30 + for user in users[name]:
1.31 + values = user._attrnames[name]
1.32 + if values is None:
1.33 + values = user._attrnames[name] = ObjectSet()
1.34 +
1.35 + # Add an entry for the attribute, optionally with an assigned
1.36 + # value.
1.37 +
1.38 + values.add(attrname)
1.39 + if value is not None:
1.40 + values[attrname].add(value)
1.41 +
1.42 + return users[name]
1.43
1.44 def _define_attribute_user(self, node):
1.45
2.1 --- a/micropython/inspect.py Fri Jun 29 01:44:08 2012 +0200
2.2 +++ b/micropython/inspect.py Sat Jun 30 00:02:31 2012 +0200
2.3 @@ -598,11 +598,14 @@
2.4 where such attributes are inferred from the usage.
2.5 """
2.6
2.7 - # Access to attribute via a local in functions or classes but not
2.8 + # Access to attributes via a local in functions or classes but not
2.9 # modules (since module-level locals are globals that can be modified
2.10 - # independently of the namespace).
2.11 + # independently of the namespace), or access via a module global within
2.12 + # a function.
2.13
2.14 - if expr.parent is self.get_namespace() and not self.get_namespace() is self:
2.15 + if expr.parent is self.get_namespace() and not self.get_namespace() is self or \
2.16 + expr.parent is self and self.in_function:
2.17 +
2.18 self.define_attribute_accessor(expr.name, attrname, node, value)
2.19 else:
2.20 self.use_name(attrname, node.expr, value, ns=expr.parent)