1.1 --- a/annotate.py Sat Dec 16 01:14:18 2006 +0100
1.2 +++ b/annotate.py Sat Jan 06 00:45:33 2007 +0100
1.3 @@ -948,6 +948,12 @@
1.4 namespace.merge_items(items)
1.5 using_module_namespace = 0
1.6
1.7 + # NOTE: Avoid PEP 227 (nested scopes) whilst permitting references to a
1.8 + # NOTE: subprogram within itself.
1.9 +
1.10 + if hasattr(target, "name") and target.name is not None:
1.11 + namespace.store(target.name, [Attribute(None, target)])
1.12 +
1.13 # Process the subprogram.
1.14 # In order to keep global accesses working, the module namespace must be
1.15 # adjusted.
2.1 --- a/fixnames.py Sat Dec 16 01:14:18 2006 +0100
2.2 +++ b/fixnames.py Sat Jan 06 00:45:33 2007 +0100
2.3 @@ -164,6 +164,12 @@
2.4 if namespace is not None:
2.5 self.namespace.merge_namespace(namespace)
2.6
2.7 + # NOTE: Avoid PEP 227 (nested scopes) whilst permitting references to a
2.8 + # NOTE: subprogram within itself.
2.9 +
2.10 + if hasattr(node, "name") and node.name is not None:
2.11 + self.namespace.store(node.name)
2.12 +
2.13 # Register the names of parameters in the namespace.
2.14
2.15 if hasattr(node, "params"):
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/tests/nested_classes.py Sat Jan 06 00:45:33 2007 +0100
3.3 @@ -0,0 +1,6 @@
3.4 +def f():
3.5 + class C:
3.6 + pass
3.7 + return C
3.8 +
3.9 +c = f()
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/tests/nested_functions.py Sat Jan 06 00:45:33 2007 +0100
4.3 @@ -0,0 +1,9 @@
4.4 +def f():
4.5 + def g(x):
4.6 + if x <= 0:
4.7 + return x
4.8 + return g(x - 1) + x
4.9 + return g
4.10 +
4.11 +a = f()
4.12 +b = a(3)
5.1 --- a/viewer.py Sat Dec 16 01:14:18 2006 +0100
5.2 +++ b/viewer.py Sat Jan 06 00:45:33 2007 +0100
5.3 @@ -872,7 +872,13 @@
5.4 self._types_list(node.namespace.raises, style_class="raises")
5.5
5.6 def _scopes(self, node):
5.7 - if not isinstance(node, LoadName):
5.8 + if isinstance(node, StoreName) or isinstance(node, LoadName):
5.9 + self.stream.write("<div class='scopes'>\n")
5.10 + self.stream.write("<div class='scope'>")
5.11 + self.stream.write("(local)")
5.12 + self.stream.write("</div>\n")
5.13 + self.stream.write("</div>\n")
5.14 + else:
5.15 if hasattr(node, "writes") and node.writes or hasattr(node, "accesses") and node.accesses:
5.16 self.stream.write("<div class='scopes'>\n")
5.17 for ref in getattr(node, "writes", getattr(node, "accesses", {})).keys():