1.1 --- a/common.py Tue Mar 07 22:21:58 2017 +0100
1.2 +++ b/common.py Wed Mar 08 00:49:21 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.