MCPcopy Index your code
hub / github.com/python/mypy / FinallyNonlocalControl

Class FinallyNonlocalControl

mypyc/irbuild/nonlocalcontrol.py:199–216  ·  view source on GitHub ↗

Nonlocal control for finally blocks. Just makes sure that sys.exc_info always gets restored when we leave and the return register is decrefed if it isn't null.

Source from the content-addressed store, hash-verified

197
198
199class FinallyNonlocalControl(CleanupNonlocalControl):
200 """Nonlocal control for finally blocks.
201
202 Just makes sure that sys.exc_info always gets restored when we
203 leave and the return register is decrefed if it isn't null.
204 """
205
206 def __init__(self, outer: NonlocalControl, saved: Value) -> None:
207 super().__init__(outer)
208 self.saved = saved
209
210 def gen_cleanup(self, builder: IRBuilder, line: int) -> None:
211 # Restore the old exc_info
212 target, cleanup = BasicBlock(), BasicBlock()
213 builder.add(Branch(self.saved, target, cleanup, Branch.IS_ERROR))
214 builder.activate_block(cleanup)
215 builder.call_c(restore_exc_info_op, [self.saved], line)
216 builder.goto_and_activate(target)

Callers 1

try_finally_bodyFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…