def PyEval_EvalCode(space, w_code, w_globals, w_locals): """This is a simplified interface to PyEval_EvalCodeEx(), with just the code object, and the dictionaries of global and local variables. The other arguments are set to NULL.""" if w_globals is None: w_globals = space.w_None if w_locals is None: w_locals = space.w_None return compiling.eval(space, w_code, w_globals, w_locals)
def run_string(space, source, filename, start, w_globals, w_locals): w_source = space.wrap(source) start = rffi.cast(lltype.Signed, start) if start == Py_file_input: mode = 'exec' elif start == Py_eval_input: mode = 'eval' elif start == Py_single_input: mode = 'single' else: raise OperationError(space.w_ValueError, space.wrap( "invalid mode parameter for PyRun_String")) w_code = compiling.compile(space, w_source, filename, mode) return compiling.eval(space, w_code, w_globals, w_locals)
def PyRun_StringFlags(space, source, start, w_globals, w_locals, flagsptr): """Execute Python source code from str in the context specified by the dictionaries globals and locals with the compiler flags specified by flags. The parameter start specifies the start token that should be used to parse the source code. Returns the result of executing the code as a Python object, or NULL if an exception was raised.""" source = rffi.charp2str(source) if flagsptr: flags = rffi.cast(lltype.Signed, flagsptr.c_cf_flags) else: flags = 0 w_code = compile_string(space, source, "<string>", start, flags) return compiling.eval(space, w_code, w_globals, w_locals)
def run_string(space, source, filename, start, w_globals, w_locals): w_code = compile_string(space, source, filename, start) return compiling.eval(space, w_code, w_globals, w_locals)