1.1 --- a/common.py Tue Mar 07 22:22:32 2017 +0100
1.2 +++ b/common.py Wed Mar 08 00:50:13 2017 +0100
1.3 @@ -775,16 +775,17 @@
1.4
1.5 return isinstance(node.expr, compiler.ast.Getattr)
1.6
1.7 - def get_name_for_tracking(self, name, name_ref=None):
1.8 + def get_name_for_tracking(self, name, name_ref=None, is_global=False):
1.9
1.10 """
1.11 Return the name to be used for attribute usage observations involving
1.12 the given 'name' in the current namespace.
1.13
1.14 If the name is being used outside a function, and if 'name_ref' is
1.15 - given, a path featuring the name in the global namespace is returned
1.16 - where 'name_ref' indicates a global. Otherwise, a path computed using
1.17 - the current namespace and the given name is returned.
1.18 + given and indicates a global or if 'is_global' is specified as a true
1.19 + value, a path featuring the name in the global namespace is returned.
1.20 + Otherwise, a path computed using the current namespace and the given
1.21 + name is returned.
1.22
1.23 The intention of this method is to provide a suitably-qualified name
1.24 that can be tracked across namespaces. Where globals are being
1.25 @@ -804,7 +805,7 @@
1.26
1.27 # For global names outside functions, use a global name.
1.28
1.29 - elif name_ref and name_ref.is_global_name():
1.30 + elif is_global or name_ref and name_ref.is_global_name():
1.31 return self.get_global_path(name)
1.32
1.33 # Otherwise, establish a name in the current namespace.
2.1 --- a/deducer.py Tue Mar 07 22:22:32 2017 +0100
2.2 +++ b/deducer.py Wed Mar 08 00:50:13 2017 +0100
2.3 @@ -1331,6 +1331,9 @@
2.4 self.identify_reference_attributes(access_location, attrname, class_types, instance_types, module_types, True)
2.5 self.record_reference_types(accessor_location, class_types, instance_types, module_types, True, True)
2.6
2.7 + # Define mappings between the original and access locations
2.8 + # so that translation can work from the source details.
2.9 +
2.10 original_location = (location, original_name, original_attrnames, 0)
2.11
2.12 if original_location != access_location:
3.1 --- a/translator.py Tue Mar 07 22:22:32 2017 +0100
3.2 +++ b/translator.py Wed Mar 08 00:50:13 2017 +0100
3.3 @@ -1416,7 +1416,8 @@
3.4
3.5 # Find any invocation details.
3.6
3.7 - location = self.get_access_location(n.name)
3.8 + name = self.get_name_for_tracking(n.name, is_global=is_global)
3.9 + location = self.get_access_location(name)
3.10
3.11 # Mark any local assignments as volatile in exception blocks.
3.12