# HG changeset patch # User Paul Boddie # Date 1488930613 -3600 # Node ID 52cf52febe306a1e7ea2686ca5464489c9c86857 # Parent 4ac300077dea4ea8f75271336ed7df99904cce90# Parent 25e7ca6806c6235d63df12c91b2473efefb586f1 Merged changes from the default branch. diff -r 4ac300077dea -r 52cf52febe30 common.py --- a/common.py Tue Mar 07 22:22:32 2017 +0100 +++ b/common.py Wed Mar 08 00:50:13 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 4ac300077dea -r 52cf52febe30 deducer.py --- a/deducer.py Tue Mar 07 22:22:32 2017 +0100 +++ b/deducer.py Wed Mar 08 00:50:13 2017 +0100 @@ -1331,6 +1331,9 @@ self.identify_reference_attributes(access_location, attrname, class_types, instance_types, module_types, True) self.record_reference_types(accessor_location, class_types, instance_types, module_types, True, True) + # Define mappings between the original and access locations + # so that translation can work from the source details. + original_location = (location, original_name, original_attrnames, 0) if original_location != access_location: diff -r 4ac300077dea -r 52cf52febe30 translator.py --- a/translator.py Tue Mar 07 22:22:32 2017 +0100 +++ b/translator.py Wed Mar 08 00:50:13 2017 +0100 @@ -1416,7 +1416,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.