def do_try_except_block(self, block):
        
        while 1:
            instr = block.pop(-1)
            if instr.opname == 'POP_BLOCK':
                break

        try_except = self.decompile_block(block).stmnt()
        
        finally_block = []
        while 1:
            next_instr = self.ilst.pop(0)
            if next_instr.opname == 'END_FINALLY':
                break
            finally_block.append(next_instr)

        finally_ = self.decompile_block(finally_block).stmnt()

        try_finally = _ast.TryFinally(body=try_except, finalbody=finally_)
        
        self.push_ast_item(try_finally)
Ejemplo n.º 2
0
def TryFinally(body, finalbody=None):
    finalbody = FormatAndValidateBody(finalbody)
    return _ast.TryFinally(body=body, finalbody=finalbody)