def SETUP_WITH(self, instr):
with_block = self.make_block(to=instr.to, inclusive=False)
assert with_block.pop().opname == 'LOAD_CONST'
assert with_block.pop().opname == 'POP_BLOCK'
with_cleanup = self.ilst.pop(0)
assert with_cleanup.opname == 'WITH_CLEANUP'
end_finally = self.ilst.pop(0)
assert end_finally.opname == 'END_FINALLY'
with_ = self.decompile_block(with_block, stack_items=['WITH_BLOCK']).stmnt()
if isinstance(with_[0], _ast.Assign) and with_[0].value == 'WITH_BLOCK':
assign = with_.pop(0)
as_ = assign.targets[0]
else:
as_ = None
body = with_
expr = self.ast_stack.pop()
with_ = _ast.With(context_expr=expr, optional_vars=as_, body=body,
lineno=instr.lineno, col_offset=0)
self.ast_stack.append(with_)
评论列表
文章目录