1.1 --- a/annotate.py Mon Nov 27 01:06:38 2006 +0100
1.2 +++ b/annotate.py Tue Nov 28 00:37:12 2006 +0100
1.3 @@ -485,6 +485,9 @@
1.4 self.namespace.snapshot()
1.5 return return_
1.6
1.7 + visitReturnFromBlock = visitReturn
1.8 + visitReturnFromFunction = visitReturn
1.9 +
1.10 def visitStoreAttr(self, storeattr):
1.11 storeattr.expr = self.dispatch(storeattr.expr)
1.12 expr = self.namespace.types
1.13 @@ -718,8 +721,23 @@
1.14
1.15 if getattr(invoke, "share_locals", 0):
1.16 self.namespace.reset()
1.17 +
1.18 + # Merge the locals snapshots.
1.19 +
1.20 for locals in self.returned_locals:
1.21 - self.namespace.merge_namespace(locals, everything=0)
1.22 +
1.23 + # For blocks returning values (such as operations), do not merge
1.24 + # snapshots or results.
1.25 +
1.26 + if getattr(target, "returns_value", 0):
1.27 + self.namespace.merge_namespace(locals, everything=0)
1.28 +
1.29 + # For blocks not returning values (such as loops), merge
1.30 + # snapshots and results since they contain details of genuine
1.31 + # returns.
1.32 +
1.33 + else:
1.34 + self.namespace.merge_namespace(locals)
1.35
1.36 # Incorporate any raised exceptions.
1.37