# HG changeset patch # User Paul Boddie # Date 1488930561 -3600 # Node ID fe6046254d69f33609ca0ba8ece5f1da48448aca # Parent b5fd9597bfabeac5bed3b739d29771dfc9fd4844 Use the appropriate access location for name references during translation. diff -r b5fd9597bfab -r fe6046254d69 common.py --- a/common.py Tue Mar 07 22:21:58 2017 +0100 +++ b/common.py Wed Mar 08 00:49:21 2017 +0100 @@ -775,16 +775,17 @@ return isinstance(node.expr, compiler.ast.Getattr) - def get_name_for_tracking(self, name, name_ref=None): + def get_name_for_tracking(self, name, name_ref=None, is_global=False): """ Return the name to be used for attribute usage observations involving the given 'name' in the current namespace. If the name is being used outside a function, and if 'name_ref' is - given, a path featuring the name in the global namespace is returned - where 'name_ref' indicates a global. Otherwise, a path computed using - the current namespace and the given name is returned. + given and indicates a global or if 'is_global' is specified as a true + value, a path featuring the name in the global namespace is returned. + Otherwise, a path computed using the current namespace and the given + name is returned. The intention of this method is to provide a suitably-qualified name that can be tracked across namespaces. Where globals are being @@ -804,7 +805,7 @@ # For global names outside functions, use a global name. - elif name_ref and name_ref.is_global_name(): + elif is_global or name_ref and name_ref.is_global_name(): return self.get_global_path(name) # Otherwise, establish a name in the current namespace. diff -r b5fd9597bfab -r fe6046254d69 translator.py --- a/translator.py Tue Mar 07 22:21:58 2017 +0100 +++ b/translator.py Wed Mar 08 00:49:21 2017 +0100 @@ -1414,7 +1414,8 @@ # Find any invocation details. - location = self.get_access_location(n.name) + name = self.get_name_for_tracking(n.name, is_global=is_global) + location = self.get_access_location(name) # Mark any local assignments as volatile in exception blocks.