xref: /third_party/python/Doc/c-api/veryhigh.rst (revision 7db96d56)
17db96d56Sopenharmony_ci.. highlight:: c
27db96d56Sopenharmony_ci
37db96d56Sopenharmony_ci
47db96d56Sopenharmony_ci.. _veryhigh:
57db96d56Sopenharmony_ci
67db96d56Sopenharmony_ci*************************
77db96d56Sopenharmony_ciThe Very High Level Layer
87db96d56Sopenharmony_ci*************************
97db96d56Sopenharmony_ci
107db96d56Sopenharmony_ciThe functions in this chapter will let you execute Python source code given in a
117db96d56Sopenharmony_cifile or a buffer, but they will not let you interact in a more detailed way with
127db96d56Sopenharmony_cithe interpreter.
137db96d56Sopenharmony_ci
147db96d56Sopenharmony_ciSeveral of these functions accept a start symbol from the grammar as a
157db96d56Sopenharmony_ciparameter.  The available start symbols are :const:`Py_eval_input`,
167db96d56Sopenharmony_ci:const:`Py_file_input`, and :const:`Py_single_input`.  These are described
177db96d56Sopenharmony_cifollowing the functions which accept them as parameters.
187db96d56Sopenharmony_ci
197db96d56Sopenharmony_ciNote also that several of these functions take :c:expr:`FILE*` parameters.  One
207db96d56Sopenharmony_ciparticular issue which needs to be handled carefully is that the :c:expr:`FILE`
217db96d56Sopenharmony_cistructure for different C libraries can be different and incompatible.  Under
227db96d56Sopenharmony_ciWindows (at least), it is possible for dynamically linked extensions to actually
237db96d56Sopenharmony_ciuse different libraries, so care should be taken that :c:expr:`FILE*` parameters
247db96d56Sopenharmony_ciare only passed to these functions if it is certain that they were created by
257db96d56Sopenharmony_cithe same library that the Python runtime is using.
267db96d56Sopenharmony_ci
277db96d56Sopenharmony_ci
287db96d56Sopenharmony_ci.. c:function:: int Py_Main(int argc, wchar_t **argv)
297db96d56Sopenharmony_ci
307db96d56Sopenharmony_ci   The main program for the standard interpreter.  This is made available for
317db96d56Sopenharmony_ci   programs which embed Python.  The *argc* and *argv* parameters should be
327db96d56Sopenharmony_ci   prepared exactly as those which are passed to a C program's :c:func:`main`
337db96d56Sopenharmony_ci   function (converted to wchar_t according to the user's locale).  It is
347db96d56Sopenharmony_ci   important to note that the argument list may be modified (but the contents of
357db96d56Sopenharmony_ci   the strings pointed to by the argument list are not). The return value will
367db96d56Sopenharmony_ci   be ``0`` if the interpreter exits normally (i.e., without an exception),
377db96d56Sopenharmony_ci   ``1`` if the interpreter exits due to an exception, or ``2`` if the parameter
387db96d56Sopenharmony_ci   list does not represent a valid Python command line.
397db96d56Sopenharmony_ci
407db96d56Sopenharmony_ci   Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
417db96d56Sopenharmony_ci   function will not return ``1``, but exit the process, as long as
427db96d56Sopenharmony_ci   ``Py_InspectFlag`` is not set.
437db96d56Sopenharmony_ci
447db96d56Sopenharmony_ci
457db96d56Sopenharmony_ci.. c:function:: int Py_BytesMain(int argc, char **argv)
467db96d56Sopenharmony_ci
477db96d56Sopenharmony_ci   Similar to :c:func:`Py_Main` but *argv* is an array of bytes strings.
487db96d56Sopenharmony_ci
497db96d56Sopenharmony_ci   .. versionadded:: 3.8
507db96d56Sopenharmony_ci
517db96d56Sopenharmony_ci
527db96d56Sopenharmony_ci.. c:function:: int PyRun_AnyFile(FILE *fp, const char *filename)
537db96d56Sopenharmony_ci
547db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
557db96d56Sopenharmony_ci   *closeit* set to ``0`` and *flags* set to ``NULL``.
567db96d56Sopenharmony_ci
577db96d56Sopenharmony_ci
587db96d56Sopenharmony_ci.. c:function:: int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
597db96d56Sopenharmony_ci
607db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
617db96d56Sopenharmony_ci   the *closeit* argument set to ``0``.
627db96d56Sopenharmony_ci
637db96d56Sopenharmony_ci
647db96d56Sopenharmony_ci.. c:function:: int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit)
657db96d56Sopenharmony_ci
667db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
677db96d56Sopenharmony_ci   the *flags* argument set to ``NULL``.
687db96d56Sopenharmony_ci
697db96d56Sopenharmony_ci
707db96d56Sopenharmony_ci.. c:function:: int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
717db96d56Sopenharmony_ci
727db96d56Sopenharmony_ci   If *fp* refers to a file associated with an interactive device (console or
737db96d56Sopenharmony_ci   terminal input or Unix pseudo-terminal), return the value of
747db96d56Sopenharmony_ci   :c:func:`PyRun_InteractiveLoop`, otherwise return the result of
757db96d56Sopenharmony_ci   :c:func:`PyRun_SimpleFile`.  *filename* is decoded from the filesystem
767db96d56Sopenharmony_ci   encoding (:func:`sys.getfilesystemencoding`).  If *filename* is ``NULL``, this
777db96d56Sopenharmony_ci   function uses ``"???"`` as the filename.
787db96d56Sopenharmony_ci   If *closeit* is true, the file is closed before
797db96d56Sopenharmony_ci   ``PyRun_SimpleFileExFlags()`` returns.
807db96d56Sopenharmony_ci
817db96d56Sopenharmony_ci
827db96d56Sopenharmony_ci.. c:function:: int PyRun_SimpleString(const char *command)
837db96d56Sopenharmony_ci
847db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_SimpleStringFlags` below,
857db96d56Sopenharmony_ci   leaving the :c:struct:`PyCompilerFlags`\* argument set to ``NULL``.
867db96d56Sopenharmony_ci
877db96d56Sopenharmony_ci
887db96d56Sopenharmony_ci.. c:function:: int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
897db96d56Sopenharmony_ci
907db96d56Sopenharmony_ci   Executes the Python source code from *command* in the :mod:`__main__` module
917db96d56Sopenharmony_ci   according to the *flags* argument. If :mod:`__main__` does not already exist, it
927db96d56Sopenharmony_ci   is created.  Returns ``0`` on success or ``-1`` if an exception was raised.  If
937db96d56Sopenharmony_ci   there was an error, there is no way to get the exception information. For the
947db96d56Sopenharmony_ci   meaning of *flags*, see below.
957db96d56Sopenharmony_ci
967db96d56Sopenharmony_ci   Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
977db96d56Sopenharmony_ci   function will not return ``-1``, but exit the process, as long as
987db96d56Sopenharmony_ci   ``Py_InspectFlag`` is not set.
997db96d56Sopenharmony_ci
1007db96d56Sopenharmony_ci
1017db96d56Sopenharmony_ci.. c:function:: int PyRun_SimpleFile(FILE *fp, const char *filename)
1027db96d56Sopenharmony_ci
1037db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below,
1047db96d56Sopenharmony_ci   leaving *closeit* set to ``0`` and *flags* set to ``NULL``.
1057db96d56Sopenharmony_ci
1067db96d56Sopenharmony_ci
1077db96d56Sopenharmony_ci.. c:function:: int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit)
1087db96d56Sopenharmony_ci
1097db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below,
1107db96d56Sopenharmony_ci   leaving *flags* set to ``NULL``.
1117db96d56Sopenharmony_ci
1127db96d56Sopenharmony_ci
1137db96d56Sopenharmony_ci.. c:function:: int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
1147db96d56Sopenharmony_ci
1157db96d56Sopenharmony_ci   Similar to :c:func:`PyRun_SimpleStringFlags`, but the Python source code is read
1167db96d56Sopenharmony_ci   from *fp* instead of an in-memory string. *filename* should be the name of
1177db96d56Sopenharmony_ci   the file, it is decoded from :term:`filesystem encoding and error handler`.
1187db96d56Sopenharmony_ci   If *closeit* is true, the file is closed before
1197db96d56Sopenharmony_ci   ``PyRun_SimpleFileExFlags()`` returns.
1207db96d56Sopenharmony_ci
1217db96d56Sopenharmony_ci   .. note::
1227db96d56Sopenharmony_ci      On Windows, *fp* should be opened as binary mode (e.g. ``fopen(filename, "rb")``).
1237db96d56Sopenharmony_ci      Otherwise, Python may not handle script file with LF line ending correctly.
1247db96d56Sopenharmony_ci
1257db96d56Sopenharmony_ci
1267db96d56Sopenharmony_ci.. c:function:: int PyRun_InteractiveOne(FILE *fp, const char *filename)
1277db96d56Sopenharmony_ci
1287db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_InteractiveOneFlags` below,
1297db96d56Sopenharmony_ci   leaving *flags* set to ``NULL``.
1307db96d56Sopenharmony_ci
1317db96d56Sopenharmony_ci
1327db96d56Sopenharmony_ci.. c:function:: int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
1337db96d56Sopenharmony_ci
1347db96d56Sopenharmony_ci   Read and execute a single statement from a file associated with an
1357db96d56Sopenharmony_ci   interactive device according to the *flags* argument.  The user will be
1367db96d56Sopenharmony_ci   prompted using ``sys.ps1`` and ``sys.ps2``.  *filename* is decoded from the
1377db96d56Sopenharmony_ci   :term:`filesystem encoding and error handler`.
1387db96d56Sopenharmony_ci
1397db96d56Sopenharmony_ci   Returns ``0`` when the input was
1407db96d56Sopenharmony_ci   executed successfully, ``-1`` if there was an exception, or an error code
1417db96d56Sopenharmony_ci   from the :file:`errcode.h` include file distributed as part of Python if
1427db96d56Sopenharmony_ci   there was a parse error.  (Note that :file:`errcode.h` is not included by
1437db96d56Sopenharmony_ci   :file:`Python.h`, so must be included specifically if needed.)
1447db96d56Sopenharmony_ci
1457db96d56Sopenharmony_ci
1467db96d56Sopenharmony_ci.. c:function:: int PyRun_InteractiveLoop(FILE *fp, const char *filename)
1477db96d56Sopenharmony_ci
1487db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_InteractiveLoopFlags` below,
1497db96d56Sopenharmony_ci   leaving *flags* set to ``NULL``.
1507db96d56Sopenharmony_ci
1517db96d56Sopenharmony_ci
1527db96d56Sopenharmony_ci.. c:function:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
1537db96d56Sopenharmony_ci
1547db96d56Sopenharmony_ci   Read and execute statements from a file associated with an interactive device
1557db96d56Sopenharmony_ci   until EOF is reached.  The user will be prompted using ``sys.ps1`` and
1567db96d56Sopenharmony_ci   ``sys.ps2``.  *filename* is decoded from the :term:`filesystem encoding and
1577db96d56Sopenharmony_ci   error handler`.  Returns ``0`` at EOF or a negative number upon failure.
1587db96d56Sopenharmony_ci
1597db96d56Sopenharmony_ci
1607db96d56Sopenharmony_ci.. c:var:: int (*PyOS_InputHook)(void)
1617db96d56Sopenharmony_ci
1627db96d56Sopenharmony_ci   Can be set to point to a function with the prototype
1637db96d56Sopenharmony_ci   ``int func(void)``.  The function will be called when Python's
1647db96d56Sopenharmony_ci   interpreter prompt is about to become idle and wait for user input
1657db96d56Sopenharmony_ci   from the terminal.  The return value is ignored.  Overriding this
1667db96d56Sopenharmony_ci   hook can be used to integrate the interpreter's prompt with other
1677db96d56Sopenharmony_ci   event loops, as done in the :file:`Modules/_tkinter.c` in the
1687db96d56Sopenharmony_ci   Python source code.
1697db96d56Sopenharmony_ci
1707db96d56Sopenharmony_ci
1717db96d56Sopenharmony_ci.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *)
1727db96d56Sopenharmony_ci
1737db96d56Sopenharmony_ci   Can be set to point to a function with the prototype
1747db96d56Sopenharmony_ci   ``char *func(FILE *stdin, FILE *stdout, char *prompt)``,
1757db96d56Sopenharmony_ci   overriding the default function used to read a single line of input
1767db96d56Sopenharmony_ci   at the interpreter's prompt.  The function is expected to output
1777db96d56Sopenharmony_ci   the string *prompt* if it's not ``NULL``, and then read a line of
1787db96d56Sopenharmony_ci   input from the provided standard input file, returning the
1797db96d56Sopenharmony_ci   resulting string.  For example, The :mod:`readline` module sets
1807db96d56Sopenharmony_ci   this hook to provide line-editing and tab-completion features.
1817db96d56Sopenharmony_ci
1827db96d56Sopenharmony_ci   The result must be a string allocated by :c:func:`PyMem_RawMalloc` or
1837db96d56Sopenharmony_ci   :c:func:`PyMem_RawRealloc`, or ``NULL`` if an error occurred.
1847db96d56Sopenharmony_ci
1857db96d56Sopenharmony_ci   .. versionchanged:: 3.4
1867db96d56Sopenharmony_ci      The result must be allocated by :c:func:`PyMem_RawMalloc` or
1877db96d56Sopenharmony_ci      :c:func:`PyMem_RawRealloc`, instead of being allocated by
1887db96d56Sopenharmony_ci      :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`.
1897db96d56Sopenharmony_ci
1907db96d56Sopenharmony_ci.. c:function:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)
1917db96d56Sopenharmony_ci
1927db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving
1937db96d56Sopenharmony_ci   *flags* set to ``NULL``.
1947db96d56Sopenharmony_ci
1957db96d56Sopenharmony_ci
1967db96d56Sopenharmony_ci.. c:function:: PyObject* PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
1977db96d56Sopenharmony_ci
1987db96d56Sopenharmony_ci   Execute Python source code from *str* in the context specified by the
1997db96d56Sopenharmony_ci   objects *globals* and *locals* with the compiler flags specified by
2007db96d56Sopenharmony_ci   *flags*.  *globals* must be a dictionary; *locals* can be any object
2017db96d56Sopenharmony_ci   that implements the mapping protocol.  The parameter *start* specifies
2027db96d56Sopenharmony_ci   the start token that should be used to parse the source code.
2037db96d56Sopenharmony_ci
2047db96d56Sopenharmony_ci   Returns the result of executing the code as a Python object, or ``NULL`` if an
2057db96d56Sopenharmony_ci   exception was raised.
2067db96d56Sopenharmony_ci
2077db96d56Sopenharmony_ci
2087db96d56Sopenharmony_ci.. c:function:: PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals)
2097db96d56Sopenharmony_ci
2107db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
2117db96d56Sopenharmony_ci   *closeit* set to ``0`` and *flags* set to ``NULL``.
2127db96d56Sopenharmony_ci
2137db96d56Sopenharmony_ci
2147db96d56Sopenharmony_ci.. c:function:: PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit)
2157db96d56Sopenharmony_ci
2167db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
2177db96d56Sopenharmony_ci   *flags* set to ``NULL``.
2187db96d56Sopenharmony_ci
2197db96d56Sopenharmony_ci
2207db96d56Sopenharmony_ci.. c:function:: PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
2217db96d56Sopenharmony_ci
2227db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
2237db96d56Sopenharmony_ci   *closeit* set to ``0``.
2247db96d56Sopenharmony_ci
2257db96d56Sopenharmony_ci
2267db96d56Sopenharmony_ci.. c:function:: PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags)
2277db96d56Sopenharmony_ci
2287db96d56Sopenharmony_ci   Similar to :c:func:`PyRun_StringFlags`, but the Python source code is read from
2297db96d56Sopenharmony_ci   *fp* instead of an in-memory string. *filename* should be the name of the file,
2307db96d56Sopenharmony_ci   it is decoded from the :term:`filesystem encoding and error handler`.
2317db96d56Sopenharmony_ci   If *closeit* is true, the file is closed before :c:func:`PyRun_FileExFlags`
2327db96d56Sopenharmony_ci   returns.
2337db96d56Sopenharmony_ci
2347db96d56Sopenharmony_ci
2357db96d56Sopenharmony_ci.. c:function:: PyObject* Py_CompileString(const char *str, const char *filename, int start)
2367db96d56Sopenharmony_ci
2377db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`Py_CompileStringFlags` below, leaving
2387db96d56Sopenharmony_ci   *flags* set to ``NULL``.
2397db96d56Sopenharmony_ci
2407db96d56Sopenharmony_ci
2417db96d56Sopenharmony_ci.. c:function:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags)
2427db96d56Sopenharmony_ci
2437db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`Py_CompileStringExFlags` below, with
2447db96d56Sopenharmony_ci   *optimize* set to ``-1``.
2457db96d56Sopenharmony_ci
2467db96d56Sopenharmony_ci
2477db96d56Sopenharmony_ci.. c:function:: PyObject* Py_CompileStringObject(const char *str, PyObject *filename, int start, PyCompilerFlags *flags, int optimize)
2487db96d56Sopenharmony_ci
2497db96d56Sopenharmony_ci   Parse and compile the Python source code in *str*, returning the resulting code
2507db96d56Sopenharmony_ci   object.  The start token is given by *start*; this can be used to constrain the
2517db96d56Sopenharmony_ci   code which can be compiled and should be :const:`Py_eval_input`,
2527db96d56Sopenharmony_ci   :const:`Py_file_input`, or :const:`Py_single_input`.  The filename specified by
2537db96d56Sopenharmony_ci   *filename* is used to construct the code object and may appear in tracebacks or
2547db96d56Sopenharmony_ci   :exc:`SyntaxError` exception messages.  This returns ``NULL`` if the code
2557db96d56Sopenharmony_ci   cannot be parsed or compiled.
2567db96d56Sopenharmony_ci
2577db96d56Sopenharmony_ci   The integer *optimize* specifies the optimization level of the compiler; a
2587db96d56Sopenharmony_ci   value of ``-1`` selects the optimization level of the interpreter as given by
2597db96d56Sopenharmony_ci   :option:`-O` options.  Explicit levels are ``0`` (no optimization;
2607db96d56Sopenharmony_ci   ``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false)
2617db96d56Sopenharmony_ci   or ``2`` (docstrings are removed too).
2627db96d56Sopenharmony_ci
2637db96d56Sopenharmony_ci   .. versionadded:: 3.4
2647db96d56Sopenharmony_ci
2657db96d56Sopenharmony_ci
2667db96d56Sopenharmony_ci.. c:function:: PyObject* Py_CompileStringExFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags, int optimize)
2677db96d56Sopenharmony_ci
2687db96d56Sopenharmony_ci   Like :c:func:`Py_CompileStringObject`, but *filename* is a byte string
2697db96d56Sopenharmony_ci   decoded from the :term:`filesystem encoding and error handler`.
2707db96d56Sopenharmony_ci
2717db96d56Sopenharmony_ci   .. versionadded:: 3.2
2727db96d56Sopenharmony_ci
2737db96d56Sopenharmony_ci.. c:function:: PyObject* PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)
2747db96d56Sopenharmony_ci
2757db96d56Sopenharmony_ci   This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just
2767db96d56Sopenharmony_ci   the code object, and global and local variables.  The other arguments are
2777db96d56Sopenharmony_ci   set to ``NULL``.
2787db96d56Sopenharmony_ci
2797db96d56Sopenharmony_ci
2807db96d56Sopenharmony_ci.. c:function:: PyObject* PyEval_EvalCodeEx(PyObject *co, PyObject *globals, PyObject *locals, PyObject *const *args, int argcount, PyObject *const *kws, int kwcount, PyObject *const *defs, int defcount, PyObject *kwdefs, PyObject *closure)
2817db96d56Sopenharmony_ci
2827db96d56Sopenharmony_ci   Evaluate a precompiled code object, given a particular environment for its
2837db96d56Sopenharmony_ci   evaluation.  This environment consists of a dictionary of global variables,
2847db96d56Sopenharmony_ci   a mapping object of local variables, arrays of arguments, keywords and
2857db96d56Sopenharmony_ci   defaults, a dictionary of default values for :ref:`keyword-only
2867db96d56Sopenharmony_ci   <keyword-only_parameter>` arguments and a closure tuple of cells.
2877db96d56Sopenharmony_ci
2887db96d56Sopenharmony_ci
2897db96d56Sopenharmony_ci.. c:function:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
2907db96d56Sopenharmony_ci
2917db96d56Sopenharmony_ci   Evaluate an execution frame.  This is a simplified interface to
2927db96d56Sopenharmony_ci   :c:func:`PyEval_EvalFrameEx`, for backward compatibility.
2937db96d56Sopenharmony_ci
2947db96d56Sopenharmony_ci
2957db96d56Sopenharmony_ci.. c:function:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
2967db96d56Sopenharmony_ci
2977db96d56Sopenharmony_ci   This is the main, unvarnished function of Python interpretation.  The code
2987db96d56Sopenharmony_ci   object associated with the execution frame *f* is executed, interpreting
2997db96d56Sopenharmony_ci   bytecode and executing calls as needed.  The additional *throwflag*
3007db96d56Sopenharmony_ci   parameter can mostly be ignored - if true, then it causes an exception
3017db96d56Sopenharmony_ci   to immediately be thrown; this is used for the :meth:`~generator.throw`
3027db96d56Sopenharmony_ci   methods of generator objects.
3037db96d56Sopenharmony_ci
3047db96d56Sopenharmony_ci   .. versionchanged:: 3.4
3057db96d56Sopenharmony_ci      This function now includes a debug assertion to help ensure that it
3067db96d56Sopenharmony_ci      does not silently discard an active exception.
3077db96d56Sopenharmony_ci
3087db96d56Sopenharmony_ci
3097db96d56Sopenharmony_ci.. c:function:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
3107db96d56Sopenharmony_ci
3117db96d56Sopenharmony_ci   This function changes the flags of the current evaluation frame, and returns
3127db96d56Sopenharmony_ci   true on success, false on failure.
3137db96d56Sopenharmony_ci
3147db96d56Sopenharmony_ci
3157db96d56Sopenharmony_ci.. c:var:: int Py_eval_input
3167db96d56Sopenharmony_ci
3177db96d56Sopenharmony_ci   .. index:: single: Py_CompileString()
3187db96d56Sopenharmony_ci
3197db96d56Sopenharmony_ci   The start symbol from the Python grammar for isolated expressions; for use with
3207db96d56Sopenharmony_ci   :c:func:`Py_CompileString`.
3217db96d56Sopenharmony_ci
3227db96d56Sopenharmony_ci
3237db96d56Sopenharmony_ci.. c:var:: int Py_file_input
3247db96d56Sopenharmony_ci
3257db96d56Sopenharmony_ci   .. index:: single: Py_CompileString()
3267db96d56Sopenharmony_ci
3277db96d56Sopenharmony_ci   The start symbol from the Python grammar for sequences of statements as read
3287db96d56Sopenharmony_ci   from a file or other source; for use with :c:func:`Py_CompileString`.  This is
3297db96d56Sopenharmony_ci   the symbol to use when compiling arbitrarily long Python source code.
3307db96d56Sopenharmony_ci
3317db96d56Sopenharmony_ci
3327db96d56Sopenharmony_ci.. c:var:: int Py_single_input
3337db96d56Sopenharmony_ci
3347db96d56Sopenharmony_ci   .. index:: single: Py_CompileString()
3357db96d56Sopenharmony_ci
3367db96d56Sopenharmony_ci   The start symbol from the Python grammar for a single statement; for use with
3377db96d56Sopenharmony_ci   :c:func:`Py_CompileString`. This is the symbol used for the interactive
3387db96d56Sopenharmony_ci   interpreter loop.
3397db96d56Sopenharmony_ci
3407db96d56Sopenharmony_ci
3417db96d56Sopenharmony_ci.. c:struct:: PyCompilerFlags
3427db96d56Sopenharmony_ci
3437db96d56Sopenharmony_ci   This is the structure used to hold compiler flags.  In cases where code is only
3447db96d56Sopenharmony_ci   being compiled, it is passed as ``int flags``, and in cases where code is being
3457db96d56Sopenharmony_ci   executed, it is passed as ``PyCompilerFlags *flags``.  In this case, ``from
3467db96d56Sopenharmony_ci   __future__ import`` can modify *flags*.
3477db96d56Sopenharmony_ci
3487db96d56Sopenharmony_ci   Whenever ``PyCompilerFlags *flags`` is ``NULL``, :attr:`cf_flags` is treated as
3497db96d56Sopenharmony_ci   equal to ``0``, and any modification due to ``from __future__ import`` is
3507db96d56Sopenharmony_ci   discarded.
3517db96d56Sopenharmony_ci
3527db96d56Sopenharmony_ci   .. c:member:: int cf_flags
3537db96d56Sopenharmony_ci
3547db96d56Sopenharmony_ci      Compiler flags.
3557db96d56Sopenharmony_ci
3567db96d56Sopenharmony_ci   .. c:member:: int cf_feature_version
3577db96d56Sopenharmony_ci
3587db96d56Sopenharmony_ci      *cf_feature_version* is the minor Python version. It should be
3597db96d56Sopenharmony_ci      initialized to ``PY_MINOR_VERSION``.
3607db96d56Sopenharmony_ci
3617db96d56Sopenharmony_ci      The field is ignored by default, it is used if and only if
3627db96d56Sopenharmony_ci      ``PyCF_ONLY_AST`` flag is set in *cf_flags*.
3637db96d56Sopenharmony_ci
3647db96d56Sopenharmony_ci   .. versionchanged:: 3.8
3657db96d56Sopenharmony_ci      Added *cf_feature_version* field.
3667db96d56Sopenharmony_ci
3677db96d56Sopenharmony_ci
3687db96d56Sopenharmony_ci.. c:var:: int CO_FUTURE_DIVISION
3697db96d56Sopenharmony_ci
3707db96d56Sopenharmony_ci   This bit can be set in *flags* to cause division operator ``/`` to be
3717db96d56Sopenharmony_ci   interpreted as "true division" according to :pep:`238`.
372