def test_exc_rewrite(self): func = Function("foo", [], types.Function(types.Void, (), False)) entry = func.new_block("entry") catch_block = func.new_block("catch") b = Builder(func) with b.at_front(entry): b.exc_setup([catch_block]) b.exc_throw(Const(StopIteration, types.Exception)) with b.at_front(catch_block): b.exc_catch([Const(Exception, types.Exception)]) local_exceptions.run(func, {}) self.assertNotIn('exc_throw', opcodes(func))
def test_exc_rewrite(self): func = Function("foo", [], types.Function(types.Void, ())) entry = func.new_block("entry") catch_block = func.new_block("catch") b = Builder(func) with b.at_front(entry): b.exc_setup([catch_block]) b.exc_throw(Const(StopIteration, types.Exception)) with b.at_front(catch_block): b.exc_catch([Const(Exception, types.Exception)]) local_exceptions.run(func, {}) print(func)