1.1 --- a/simplify/fixnames.py Tue Aug 28 00:59:09 2007 +0200
1.2 +++ b/simplify/fixnames.py Tue Sep 04 01:06:47 2007 +0200
1.3 @@ -108,19 +108,13 @@
1.4 # First, process the top-level code, finding out which names are
1.5 # defined at that level.
1.6
1.7 - self.global_namespace = None
1.8 + self.global_namespace = self.namespace = NameOrganiser()
1.9 self.module = module
1.10 self.builtins = builtins or module
1.11
1.12 - self.process_node(self.module)
1.13 + self.process_node(self.module, self.namespace)
1.14
1.15 - # Then, process all functions and methods, providing a global namespace.
1.16 - # By setting a global namespace, we influence the resolution of names:
1.17 - # those which are global to the top-level module (processed above) are
1.18 - # considered as built-in names, whereas those which are global to a
1.19 - # function or method are searched for in the global namespace.
1.20 -
1.21 - self.global_namespace = self.namespace
1.22 + # Then, process all functions and methods.
1.23
1.24 for subprogram in self.module.simplifier.subprograms:
1.25
1.26 @@ -268,7 +262,7 @@
1.27
1.28 # Where a distinct global namespace exists, examine it.
1.29
1.30 - if self.global_namespace is not None:
1.31 + if self.global_namespace is not self.namespace:
1.32 scope = self.global_namespace.find_for_load(loadname.name)
1.33
1.34 # Where the name is outside the global namespace, it must be a
1.35 @@ -313,7 +307,7 @@
1.36
1.37 # Where a distinct global namespace exists, it must be a local.
1.38
1.39 - if self.global_namespace is not None:
1.40 + if self.global_namespace is not self.namespace:
1.41 result = loadname
1.42
1.43 # Otherwise, we must be accessing a global (which is local at the
1.44 @@ -370,7 +364,7 @@
1.45
1.46 # If a distinct global namespace exists, it must be a local access.
1.47
1.48 - if self.global_namespace is not None:
1.49 + if self.global_namespace is not self.namespace:
1.50 return storename
1.51
1.52 # Otherwise, the name is being set at the module level and is