1.1 --- a/micropython/inspect.py Sun Jun 10 18:38:37 2012 +0200
1.2 +++ b/micropython/inspect.py Sun Jun 10 21:50:53 2012 +0200
1.3 @@ -410,6 +410,9 @@
1.4 def resume_continuing_branches(self):
1.5 self.get_namespace()._resume_continuing_branches()
1.6
1.7 + def resume_abandoned_branches(self):
1.8 + self.get_namespace()._resume_abandoned_branches()
1.9 +
1.10 def define_attribute_user(self, node):
1.11
1.12 """
1.13 @@ -1216,15 +1219,16 @@
1.14 return self._visitOperator(node, self.in_assignment and "AssSubscript" or "Subscript")
1.15
1.16 def visitTryExcept(self, node):
1.17 + self.new_branchpoint()
1.18 self.dispatch(node.body)
1.19
1.20 - self.new_branchpoint()
1.21 -
1.22 - # NOTE: Attempt to recover abandoned branches from the body.
1.23 -
1.24 for name, var, n in node.handlers:
1.25 self.new_branch(n)
1.26
1.27 + # Any abandoned branches from the body can now be resumed.
1.28 +
1.29 + self.resume_abandoned_branches()
1.30 +
1.31 # Establish the local for the handler.
1.32
1.33 if var is not None:
1.34 @@ -1234,6 +1238,10 @@
1.35
1.36 self.shelve_branch()
1.37
1.38 + # The else clause maintains the usage from the body but without the
1.39 + # abandoned branches since they would never lead to the else clause
1.40 + # being executed.
1.41 +
1.42 self.new_branch(node.else_ or NullBranch())
1.43 if node.else_ is not None:
1.44 self.dispatch(node.else_)