def run(a, b): co = deserialize(data) args = [] args.append(space.wrap(a)) args.append(space.wrap(b)) w_res = execution.run(co, args) assert isinstance(w_res, objects.Int) return w_res.value
def entry_point(argv): if len(argv) < 2: print __doc__ os._exit(1) args = argv[2:] stream = open_file_as_stream(argv[1]) co = serializer.deserialize(stream.readall()) w_args = [unwrap_arg(args[i]) for i in range(len(args))] execution.run(co, w_args) return 0
def test_nested_code_objects(self): mod = """ def f(): return 1 f()""" data = serialize(compile(mod, "spli", "exec")) spli_code = deserialize(data) assert len(spli_code.co_consts_w) == 2 assert isinstance(spli_code.co_consts_w[0], pycode.Code) assert spli_code.co_consts_w[0].co_consts_w[0] is objects.spli_None assert spli_code.co_consts_w[0].co_consts_w[1].as_int() == 1
def test_basic(self): def f(): return 1 coderepr = serialize(f.func_code) code = deserialize(coderepr) assert code.co_nlocals == f.func_code.co_nlocals assert code.co_argcount == 0 assert code.co_stacksize == f.func_code.co_stacksize assert code.co_names == [] assert self.eval(code).value == 1