# HG changeset patch # User Paul Boddie # Date 1188860807 -7200 # Node ID 0eb7bcd2b354b29f2683c0fbf86db70069f33d86 # Parent 2c3c8a3cee4573ced7dfdd6c0fef44c10a641c27 Fixed global namespace tracking (and thus base class references). diff -r 2c3c8a3cee45 -r 0eb7bcd2b354 simplify/fixnames.py --- a/simplify/fixnames.py Tue Aug 28 00:59:09 2007 +0200 +++ b/simplify/fixnames.py Tue Sep 04 01:06:47 2007 +0200 @@ -108,19 +108,13 @@ # First, process the top-level code, finding out which names are # defined at that level. - self.global_namespace = None + self.global_namespace = self.namespace = NameOrganiser() self.module = module self.builtins = builtins or module - self.process_node(self.module) + self.process_node(self.module, self.namespace) - # Then, process all functions and methods, providing a global namespace. - # By setting a global namespace, we influence the resolution of names: - # those which are global to the top-level module (processed above) are - # considered as built-in names, whereas those which are global to a - # function or method are searched for in the global namespace. - - self.global_namespace = self.namespace + # Then, process all functions and methods. for subprogram in self.module.simplifier.subprograms: @@ -268,7 +262,7 @@ # Where a distinct global namespace exists, examine it. - if self.global_namespace is not None: + if self.global_namespace is not self.namespace: scope = self.global_namespace.find_for_load(loadname.name) # Where the name is outside the global namespace, it must be a @@ -313,7 +307,7 @@ # Where a distinct global namespace exists, it must be a local. - if self.global_namespace is not None: + if self.global_namespace is not self.namespace: result = loadname # Otherwise, we must be accessing a global (which is local at the @@ -370,7 +364,7 @@ # If a distinct global namespace exists, it must be a local access. - if self.global_namespace is not None: + if self.global_namespace is not self.namespace: return storename # Otherwise, the name is being set at the module level and is