1.1 --- a/micropython/ast.py Mon Jun 01 21:10:47 2009 +0200
1.2 +++ b/micropython/ast.py Mon Jun 01 23:06:55 2009 +0200
1.3 @@ -86,6 +86,7 @@
1.4 self.label_number = 0
1.5 self.loop_blocks = []
1.6 self.exception_blocks = []
1.7 + self.in_exception_handler = 0
1.8
1.9 self.reset()
1.10
1.11 @@ -906,6 +907,10 @@
1.12 self.dispatch(compiler.ast.Name("None"))
1.13
1.14 self.new_op(StoreResult())
1.15 +
1.16 + if self.in_exception_handler:
1.17 + self.new_op(ClearException())
1.18 +
1.19 self.new_op(Return())
1.20
1.21 def visitTryExcept(self, node):
1.22 @@ -956,7 +961,10 @@
1.23
1.24 # Produce the handler code, then jump to the exit.
1.25
1.26 + self.in_exception_handler = 1
1.27 self.dispatch(handler)
1.28 + self.in_exception_handler = 0
1.29 +
1.30 self.new_op(Jump(exit_block))
1.31
1.32 self.set_block(next_block)
1.33 @@ -969,7 +977,6 @@
1.34
1.35 if node.else_ is not None:
1.36 self.set_block(else_block)
1.37 -
1.38 self.dispatch(node.else_)
1.39
1.40 # Clear the exception.