![](https://csdnimg.cn/release/download_crawler_static/1546721/bg11.jpg)
The Python/C API, Release 2.6.2
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.
PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals)
Return value: New reference.
This is a simplified interface to PyRun_FileExFlags() below, leaving closeit set to 0 and flags set to
NULL.
PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals,
int closeit)
Return value: New reference.
This is a simplified interface to PyRun_FileExFlags() below, leaving flags set to NULL.
PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject
*locals, PyCompilerFlags *flags)
Return value: New reference.
This is a simplified interface to PyRun_FileExFlags() below, leaving closeit set to 0.
PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject
*locals, int closeit, PyCompilerFlags *flags)
Return value: New reference.
Similar to PyRun_StringFlags(), but the Python source code is read from fp instead of an in-
memory string. filename should be the name of the file. If closeit is true, the file is closed before
PyRun_FileExFlags() returns.
PyObject* Py_CompileString(const char *str, const char *filename, int start)
Return value: New reference.
This is a simplified interface to Py_CompileStringFlags() below, leaving flags set to NULL.
PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags
*flags)
Return value: New reference.
Parse and compile the Python source code in str, returning the resulting code object. The start token is given
by start; this can be used to constrain the code which can be compiled and should be Py_eval_input,
Py_file_input, or Py_single_input. The filename specified by filename is used to construct the
code object and may appear in tracebacks or SyntaxError exception messages. This returns NULL if
the code cannot be parsed or compiled.
PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
Return value: New reference.
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.
PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject
**args, int argcount, PyObject **kws, int kwcount, PyObject **defs,
int defcount, PyObject *closure)
Evaluate a precompiled code object, given a particular environment for its evaluation. This environment
consists of dictionaries of global and local variables, arrays of arguments, keywords and defaults, and a
closure tuple of cells.
PyObject* PyEval_EvalFrame(PyFrameObject *f)
Evaluate an execution frame. This is a simplified interface to PyEval_EvalFrameEx, for backward compat-
ibility.
PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
This is the main, unvarnished function of Python interpretation. It is literally 2000 lines long. The code ob-
ject associated with the execution frame f is executed, interpreting bytecode and executing calls as needed.
The additional throwflag parameter can mostly be ignored - if true, then it causes an exception to immedi-
ately be thrown; this is used for the throw() methods of generator objects.
int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
This function changes the flags of the current evaluation frame, and returns true on success, false on failure.
13