Commit 58924d46 authored by Vitja Makarov's avatar Vitja Makarov

Chain exception in finally clause

parent 9fb77985
...@@ -824,6 +824,9 @@ class CreateControlFlowGraph(CythonTransform): ...@@ -824,6 +824,9 @@ class CreateControlFlowGraph(CythonTransform):
self.flow.block = entry_point self.flow.block = entry_point
self.visit(node.finally_clause) self.visit(node.finally_clause)
if self.flow.block and self.flow.exceptions:
self.flow.block.add_child(self.flow.exceptions[-1].entry_point)
# Normal execution # Normal execution
finally_enter = self.flow.newblock() finally_enter = self.flow.newblock()
self.flow.block = finally_enter self.flow.block = finally_enter
......
...@@ -100,6 +100,18 @@ def try_finally(a): ...@@ -100,6 +100,18 @@ def try_finally(a):
finally: finally:
return x return x
def try_finally_nested(m):
try:
try:
try:
f = m()
except:
pass
finally:
pass
except:
print f
_ERRORS = """ _ERRORS = """
12:12: local variable 'e' might be referenced before assignment 12:12: local variable 'e' might be referenced before assignment
12:15: local variable 'i' might be referenced before assignment 12:15: local variable 'i' might be referenced before assignment
...@@ -109,4 +121,5 @@ _ERRORS = """ ...@@ -109,4 +121,5 @@ _ERRORS = """
77:14: local variable 'oops' might be referenced before assignment 77:14: local variable 'oops' might be referenced before assignment
93:16: local variable 'x' might be referenced before assignment 93:16: local variable 'x' might be referenced before assignment
101:16: local variable 'x' might be referenced before assignment 101:16: local variable 'x' might be referenced before assignment
113:15: local variable 'f' might be referenced before assignment
""" """
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment