Esempio n. 1
0
    def _cached_compile(space, name, source, *args):
        from rpython.config.translationoption import CACHE_DIR
        from pypy.module.marshal import interp_marshal
        from pypy.interpreter.pycode import default_magic

        cachename = os.path.join(CACHE_DIR, 'frozen_importlib_%d%s' % (
            default_magic, name))
        try:
            if space.config.translating:
                raise IOError("don't use the cache when translating pypy")
            with open(cachename, 'rb') as f:
                previous = f.read(len(source) + 1)
                if previous != source + '\x00':
                    raise IOError("source changed")
                w_bin = space.newbytes(f.read())
                code_w = interp_marshal.loads(space, w_bin)
        except IOError:
            # must (re)compile the source
            ec = space.getexecutioncontext()
            code_w = ec.compiler.compile(source, *args)
            w_bin = interp_marshal.dumps(space, code_w, space.wrap(2))
            content = source + '\x00' + space.bytes_w(w_bin)
            with open(cachename, 'wb') as f:
                f.write(content)
        return code_w
Esempio n. 2
0
def command_checkwatch(cmd, marshalled_code):
    space = dbstate.space
    with non_standard_code:
        try:
            code = interp_marshal.loads(space, space.newbytes(marshalled_code))
            text = _run_watch(space, code)
        except OperationError as e:
            revdb.send_watch(e.errorstr(space), ok_flag=0)
        else:
            revdb.send_watch(text, ok_flag=1)
Esempio n. 3
0
def command_breakpoints(cmd, extra):
    space = dbstate.space
    dbstate.breakpoint_stack_id = cmd.c_arg1
    revdb.set_thread_breakpoint(cmd.c_arg2)
    dbstate.breakpoint_funcnames = None
    dbstate.breakpoint_filelines = None
    dbstate.breakpoint_by_file = None
    dbstate.breakpoint_version += 1
    watch_progs = []
    with non_standard_code:
        for i, kind, name in revdb.split_breakpoints_arg(extra):
            if kind == 'B':
                add_breakpoint(name, i)
            elif kind == 'W':
                code = interp_marshal.loads(space, space.newbytes(name))
                watch_progs.append((code, i, ''))
    dbstate.watch_progs = watch_progs[:]
Esempio n. 4
0
def entry_point():
    from pypy.module.marshal.interp_marshal import loads

    code = loads(space, space.wrap(hlstr(read_code_ptr())))
    assert isinstance(code, PyCode)
    code.exec_code(space, w_dict, w_dict)
Esempio n. 5
0
def entry_point():
    from pypy.module.marshal.interp_marshal import loads
    code = loads(space, space.wrap(hlstr(read_code_ptr())))
    assert isinstance(code, PyCode)
    code.exec_code(space, w_dict, w_dict)
Esempio n. 6
0
def PyMarshal_ReadObjectFromString(space, p, size):
    from pypy.module.marshal.interp_marshal import loads
    s = rffi.charpsize2str(p, size)
    return loads(space, space.newbytes(s))