summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/c-api%2Fveryhigh.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/python~3.12/c-api%2Fveryhigh.html')
-rw-r--r--devdocs/python~3.12/c-api%2Fveryhigh.html124
1 files changed, 124 insertions, 0 deletions
diff --git a/devdocs/python~3.12/c-api%2Fveryhigh.html b/devdocs/python~3.12/c-api%2Fveryhigh.html
new file mode 100644
index 00000000..379983b5
--- /dev/null
+++ b/devdocs/python~3.12/c-api%2Fveryhigh.html
@@ -0,0 +1,124 @@
+ <span id="veryhigh"></span><h1>The Very High Level Layer</h1> <p>The functions in this chapter will let you execute Python source code given in a file or a buffer, but they will not let you interact in a more detailed way with the interpreter.</p> <p>Several of these functions accept a start symbol from the grammar as a parameter. The available start symbols are <a class="reference internal" href="#c.Py_eval_input" title="Py_eval_input"><code>Py_eval_input</code></a>, <a class="reference internal" href="#c.Py_file_input" title="Py_file_input"><code>Py_file_input</code></a>, and <a class="reference internal" href="#c.Py_single_input" title="Py_single_input"><code>Py_single_input</code></a>. These are described following the functions which accept them as parameters.</p> <p>Note also that several of these functions take <span class="c-expr sig sig-inline c"><span class="n">FILE</span><span class="p">*</span></span> parameters. One particular issue which needs to be handled carefully is that the <code>FILE</code> structure for different C libraries can be different and incompatible. Under Windows (at least), it is possible for dynamically linked extensions to actually use different libraries, so care should be taken that <span class="c-expr sig sig-inline c"><span class="n">FILE</span><span class="p">*</span></span> parameters are only passed to these functions if it is certain that they were created by the same library that the Python runtime is using.</p> <dl class="c function"> <dt class="sig sig-object c" id="c.Py_Main">
+<code>int Py_Main(int argc, wchar_t **argv)</code> </dt> <dd>
+<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>The main program for the standard interpreter. This is made available for programs which embed Python. The <em>argc</em> and <em>argv</em> parameters should be prepared exactly as those which are passed to a C program’s <code>main()</code> function (converted to wchar_t according to the user’s locale). It is important to note that the argument list may be modified (but the contents of the strings pointed to by the argument list are not). The return value will be <code>0</code> if the interpreter exits normally (i.e., without an exception), <code>1</code> if the interpreter exits due to an exception, or <code>2</code> if the parameter list does not represent a valid Python command line.</p> <p>Note that if an otherwise unhandled <a class="reference internal" href="../library/exceptions#SystemExit" title="SystemExit"><code>SystemExit</code></a> is raised, this function will not return <code>1</code>, but exit the process, as long as <a class="reference internal" href="init_config#c.PyConfig.inspect" title="PyConfig.inspect"><code>PyConfig.inspect</code></a> is zero.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.Py_BytesMain">
+<code>int Py_BytesMain(int argc, char **argv)</code> </dt> <dd>
+<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a> since version 3.8.</em><p>Similar to <a class="reference internal" href="#c.Py_Main" title="Py_Main"><code>Py_Main()</code></a> but <em>argv</em> is an array of bytes strings.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.8.</span></p> </div> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_AnyFile">
+<code>int PyRun_AnyFile(FILE *fp, const char *filename)</code> </dt> <dd>
+<p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_AnyFileExFlags" title="PyRun_AnyFileExFlags"><code>PyRun_AnyFileExFlags()</code></a> below, leaving <em>closeit</em> set to <code>0</code> and <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_AnyFileFlags">
+<code>int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)</code> </dt> <dd>
+<p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_AnyFileExFlags" title="PyRun_AnyFileExFlags"><code>PyRun_AnyFileExFlags()</code></a> below, leaving the <em>closeit</em> argument set to <code>0</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_AnyFileEx">
+<code>int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit)</code> </dt> <dd>
+<p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_AnyFileExFlags" title="PyRun_AnyFileExFlags"><code>PyRun_AnyFileExFlags()</code></a> below, leaving the <em>flags</em> argument set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_AnyFileExFlags">
+<code>int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)</code> </dt> <dd>
+<p>If <em>fp</em> refers to a file associated with an interactive device (console or terminal input or Unix pseudo-terminal), return the value of <a class="reference internal" href="#c.PyRun_InteractiveLoop" title="PyRun_InteractiveLoop"><code>PyRun_InteractiveLoop()</code></a>, otherwise return the result of <a class="reference internal" href="#c.PyRun_SimpleFile" title="PyRun_SimpleFile"><code>PyRun_SimpleFile()</code></a>. <em>filename</em> is decoded from the filesystem encoding (<a class="reference internal" href="../library/sys#sys.getfilesystemencoding" title="sys.getfilesystemencoding"><code>sys.getfilesystemencoding()</code></a>). If <em>filename</em> is <code>NULL</code>, this function uses <code>"???"</code> as the filename. If <em>closeit</em> is true, the file is closed before <code>PyRun_SimpleFileExFlags()</code> returns.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_SimpleString">
+<code>int PyRun_SimpleString(const char *command)</code> </dt> <dd>
+<p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_SimpleStringFlags" title="PyRun_SimpleStringFlags"><code>PyRun_SimpleStringFlags()</code></a> below, leaving the <a class="reference internal" href="#c.PyCompilerFlags" title="PyCompilerFlags"><code>PyCompilerFlags</code></a>* argument set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_SimpleStringFlags">
+<code>int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)</code> </dt> <dd>
+<p>Executes the Python source code from <em>command</em> in the <a class="reference internal" href="../library/__main__#module-__main__" title="__main__: The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``."><code>__main__</code></a> module according to the <em>flags</em> argument. If <a class="reference internal" href="../library/__main__#module-__main__" title="__main__: The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``."><code>__main__</code></a> does not already exist, it is created. Returns <code>0</code> on success or <code>-1</code> if an exception was raised. If there was an error, there is no way to get the exception information. For the meaning of <em>flags</em>, see below.</p> <p>Note that if an otherwise unhandled <a class="reference internal" href="../library/exceptions#SystemExit" title="SystemExit"><code>SystemExit</code></a> is raised, this function will not return <code>-1</code>, but exit the process, as long as <a class="reference internal" href="init_config#c.PyConfig.inspect" title="PyConfig.inspect"><code>PyConfig.inspect</code></a> is zero.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_SimpleFile">
+<code>int PyRun_SimpleFile(FILE *fp, const char *filename)</code> </dt> <dd>
+<p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_SimpleFileExFlags" title="PyRun_SimpleFileExFlags"><code>PyRun_SimpleFileExFlags()</code></a> below, leaving <em>closeit</em> set to <code>0</code> and <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_SimpleFileEx">
+<code>int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit)</code> </dt> <dd>
+<p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_SimpleFileExFlags" title="PyRun_SimpleFileExFlags"><code>PyRun_SimpleFileExFlags()</code></a> below, leaving <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_SimpleFileExFlags">
+<code>int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)</code> </dt> <dd>
+<p>Similar to <a class="reference internal" href="#c.PyRun_SimpleStringFlags" title="PyRun_SimpleStringFlags"><code>PyRun_SimpleStringFlags()</code></a>, but the Python source code is read from <em>fp</em> instead of an in-memory string. <em>filename</em> should be the name of the file, it is decoded from <a class="reference internal" href="../glossary#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a>. If <em>closeit</em> is true, the file is closed before <code>PyRun_SimpleFileExFlags()</code> returns.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>On Windows, <em>fp</em> should be opened as binary mode (e.g. <code>fopen(filename, "rb")</code>). Otherwise, Python may not handle script file with LF line ending correctly.</p> </div> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_InteractiveOne">
+<code>int PyRun_InteractiveOne(FILE *fp, const char *filename)</code> </dt> <dd>
+<p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_InteractiveOneFlags" title="PyRun_InteractiveOneFlags"><code>PyRun_InteractiveOneFlags()</code></a> below, leaving <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_InteractiveOneFlags">
+<code>int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)</code> </dt> <dd>
+<p>Read and execute a single statement from a file associated with an interactive device according to the <em>flags</em> argument. The user will be prompted using <code>sys.ps1</code> and <code>sys.ps2</code>. <em>filename</em> is decoded from the <a class="reference internal" href="../glossary#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a>.</p> <p>Returns <code>0</code> when the input was executed successfully, <code>-1</code> if there was an exception, or an error code from the <code>errcode.h</code> include file distributed as part of Python if there was a parse error. (Note that <code>errcode.h</code> is not included by <code>Python.h</code>, so must be included specifically if needed.)</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_InteractiveLoop">
+<code>int PyRun_InteractiveLoop(FILE *fp, const char *filename)</code> </dt> <dd>
+<p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_InteractiveLoopFlags" title="PyRun_InteractiveLoopFlags"><code>PyRun_InteractiveLoopFlags()</code></a> below, leaving <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_InteractiveLoopFlags">
+<code>int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)</code> </dt> <dd>
+<p>Read and execute statements from a file associated with an interactive device until EOF is reached. The user will be prompted using <code>sys.ps1</code> and <code>sys.ps2</code>. <em>filename</em> is decoded from the <a class="reference internal" href="../glossary#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a>. Returns <code>0</code> at EOF or a negative number upon failure.</p> </dd>
+</dl> <dl class="c var"> <dt class="sig sig-object c" id="c.PyOS_InputHook">
+<code>int (*PyOS_InputHook)(void)</code> </dt> <dd>
+<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Can be set to point to a function with the prototype <code>int func(void)</code>. The function will be called when Python’s interpreter prompt is about to become idle and wait for user input from the terminal. The return value is ignored. Overriding this hook can be used to integrate the interpreter’s prompt with other event loops, as done in the <code>Modules/_tkinter.c</code> in the Python source code.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.12: </span>This function is only called from the <a class="reference internal" href="init#sub-interpreter-support"><span class="std std-ref">main interpreter</span></a>.</p> </div> </dd>
+</dl> <dl class="c var"> <dt class="sig sig-object c" id="c.PyOS_ReadlineFunctionPointer">
+<code>char *(*PyOS_ReadlineFunctionPointer)(FILE*, FILE*, const char*)</code> </dt> <dd>
+<p>Can be set to point to a function with the prototype <code>char *func(FILE *stdin, FILE *stdout, char *prompt)</code>, overriding the default function used to read a single line of input at the interpreter’s prompt. The function is expected to output the string <em>prompt</em> if it’s not <code>NULL</code>, and then read a line of input from the provided standard input file, returning the resulting string. For example, The <a class="reference internal" href="../library/readline#module-readline" title="readline: GNU readline support for Python. (Unix)"><code>readline</code></a> module sets this hook to provide line-editing and tab-completion features.</p> <p>The result must be a string allocated by <a class="reference internal" href="memory#c.PyMem_RawMalloc" title="PyMem_RawMalloc"><code>PyMem_RawMalloc()</code></a> or <a class="reference internal" href="memory#c.PyMem_RawRealloc" title="PyMem_RawRealloc"><code>PyMem_RawRealloc()</code></a>, or <code>NULL</code> if an error occurred.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.4: </span>The result must be allocated by <a class="reference internal" href="memory#c.PyMem_RawMalloc" title="PyMem_RawMalloc"><code>PyMem_RawMalloc()</code></a> or <a class="reference internal" href="memory#c.PyMem_RawRealloc" title="PyMem_RawRealloc"><code>PyMem_RawRealloc()</code></a>, instead of being allocated by <a class="reference internal" href="memory#c.PyMem_Malloc" title="PyMem_Malloc"><code>PyMem_Malloc()</code></a> or <a class="reference internal" href="memory#c.PyMem_Realloc" title="PyMem_Realloc"><code>PyMem_Realloc()</code></a>.</p> </div> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.12: </span>This function is only called from the <a class="reference internal" href="init#sub-interpreter-support"><span class="std std-ref">main interpreter</span></a>.</p> </div> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_String">
+<code>PyObject *PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_StringFlags" title="PyRun_StringFlags"><code>PyRun_StringFlags()</code></a> below, leaving <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_StringFlags">
+<code>PyObject *PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>Execute Python source code from <em>str</em> in the context specified by the objects <em>globals</em> and <em>locals</em> with the compiler flags specified by <em>flags</em>. <em>globals</em> must be a dictionary; <em>locals</em> can be any object that implements the mapping protocol. The parameter <em>start</em> specifies the start token that should be used to parse the source code.</p> <p>Returns the result of executing the code as a Python object, or <code>NULL</code> if an exception was raised.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_File">
+<code>PyObject *PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_FileExFlags" title="PyRun_FileExFlags"><code>PyRun_FileExFlags()</code></a> below, leaving <em>closeit</em> set to <code>0</code> and <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_FileEx">
+<code>PyObject *PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_FileExFlags" title="PyRun_FileExFlags"><code>PyRun_FileExFlags()</code></a> below, leaving <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_FileFlags">
+<code>PyObject *PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>This is a simplified interface to <a class="reference internal" href="#c.PyRun_FileExFlags" title="PyRun_FileExFlags"><code>PyRun_FileExFlags()</code></a> below, leaving <em>closeit</em> set to <code>0</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyRun_FileExFlags">
+<code>PyObject *PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>Similar to <a class="reference internal" href="#c.PyRun_StringFlags" title="PyRun_StringFlags"><code>PyRun_StringFlags()</code></a>, but the Python source code is read from <em>fp</em> instead of an in-memory string. <em>filename</em> should be the name of the file, it is decoded from the <a class="reference internal" href="../glossary#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a>. If <em>closeit</em> is true, the file is closed before <a class="reference internal" href="#c.PyRun_FileExFlags" title="PyRun_FileExFlags"><code>PyRun_FileExFlags()</code></a> returns.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.Py_CompileString">
+<code>PyObject *Py_CompileString(const char *str, const char *filename, int start)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This is a simplified interface to <a class="reference internal" href="#c.Py_CompileStringFlags" title="Py_CompileStringFlags"><code>Py_CompileStringFlags()</code></a> below, leaving <em>flags</em> set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.Py_CompileStringFlags">
+<code>PyObject *Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>This is a simplified interface to <a class="reference internal" href="#c.Py_CompileStringExFlags" title="Py_CompileStringExFlags"><code>Py_CompileStringExFlags()</code></a> below, with <em>optimize</em> set to <code>-1</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.Py_CompileStringObject">
+<code>PyObject *Py_CompileStringObject(const char *str, PyObject *filename, int start, PyCompilerFlags *flags, int optimize)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>Parse and compile the Python source code in <em>str</em>, returning the resulting code object. The start token is given by <em>start</em>; this can be used to constrain the code which can be compiled and should be <a class="reference internal" href="#c.Py_eval_input" title="Py_eval_input"><code>Py_eval_input</code></a>, <a class="reference internal" href="#c.Py_file_input" title="Py_file_input"><code>Py_file_input</code></a>, or <a class="reference internal" href="#c.Py_single_input" title="Py_single_input"><code>Py_single_input</code></a>. The filename specified by <em>filename</em> is used to construct the code object and may appear in tracebacks or <a class="reference internal" href="../library/exceptions#SyntaxError" title="SyntaxError"><code>SyntaxError</code></a> exception messages. This returns <code>NULL</code> if the code cannot be parsed or compiled.</p> <p>The integer <em>optimize</em> specifies the optimization level of the compiler; a value of <code>-1</code> selects the optimization level of the interpreter as given by <a class="reference internal" href="../using/cmdline#cmdoption-O"><code>-O</code></a> options. Explicit levels are <code>0</code> (no optimization; <code>__debug__</code> is true), <code>1</code> (asserts are removed, <code>__debug__</code> is false) or <code>2</code> (docstrings are removed too).</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.4.</span></p> </div> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.Py_CompileStringExFlags">
+<code>PyObject *Py_CompileStringExFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags, int optimize)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>Like <a class="reference internal" href="#c.Py_CompileStringObject" title="Py_CompileStringObject"><code>Py_CompileStringObject()</code></a>, but <em>filename</em> is a byte string decoded from the <a class="reference internal" href="../glossary#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a>.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyEval_EvalCode">
+<code>PyObject *PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This is a simplified interface to <a class="reference internal" href="#c.PyEval_EvalCodeEx" title="PyEval_EvalCodeEx"><code>PyEval_EvalCodeEx()</code></a>, with just the code object, and global and local variables. The other arguments are set to <code>NULL</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyEval_EvalCodeEx">
+<code>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)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Evaluate a precompiled code object, given a particular environment for its evaluation. This environment consists of a dictionary of global variables, a mapping object of local variables, arrays of arguments, keywords and defaults, a dictionary of default values for <a class="reference internal" href="../glossary#keyword-only-parameter"><span class="std std-ref">keyword-only</span></a> arguments and a closure tuple of cells.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyEval_EvalFrame">
+<code>PyObject *PyEval_EvalFrame(PyFrameObject *f)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Evaluate an execution frame. This is a simplified interface to <a class="reference internal" href="#c.PyEval_EvalFrameEx" title="PyEval_EvalFrameEx"><code>PyEval_EvalFrameEx()</code></a>, for backward compatibility.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyEval_EvalFrameEx">
+<code>PyObject *PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This is the main, unvarnished function of Python interpretation. The code object associated with the execution frame <em>f</em> is executed, interpreting bytecode and executing calls as needed. The additional <em>throwflag</em> parameter can mostly be ignored - if true, then it causes an exception to immediately be thrown; this is used for the <a class="reference internal" href="../reference/expressions#generator.throw" title="generator.throw"><code>throw()</code></a> methods of generator objects.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.4: </span>This function now includes a debug assertion to help ensure that it does not silently discard an active exception.</p> </div> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyEval_MergeCompilerFlags">
+<code>int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)</code> </dt> <dd>
+<p>This function changes the flags of the current evaluation frame, and returns true on success, false on failure.</p> </dd>
+</dl> <dl class="c var"> <dt class="sig sig-object c" id="c.Py_eval_input">
+<code>int Py_eval_input</code> </dt> <dd>
+<p id="index-0">The start symbol from the Python grammar for isolated expressions; for use with <a class="reference internal" href="#c.Py_CompileString" title="Py_CompileString"><code>Py_CompileString()</code></a>.</p> </dd>
+</dl> <dl class="c var"> <dt class="sig sig-object c" id="c.Py_file_input">
+<code>int Py_file_input</code> </dt> <dd>
+<p id="index-1">The start symbol from the Python grammar for sequences of statements as read from a file or other source; for use with <a class="reference internal" href="#c.Py_CompileString" title="Py_CompileString"><code>Py_CompileString()</code></a>. This is the symbol to use when compiling arbitrarily long Python source code.</p> </dd>
+</dl> <dl class="c var"> <dt class="sig sig-object c" id="c.Py_single_input">
+<code>int Py_single_input</code> </dt> <dd>
+<p id="index-2">The start symbol from the Python grammar for a single statement; for use with <a class="reference internal" href="#c.Py_CompileString" title="Py_CompileString"><code>Py_CompileString()</code></a>. This is the symbol used for the interactive interpreter loop.</p> </dd>
+</dl> <dl class="c struct"> <dt class="sig sig-object c" id="c.PyCompilerFlags">
+<code>struct PyCompilerFlags</code> </dt> <dd>
+<p>This is the structure used to hold compiler flags. In cases where code is only being compiled, it is passed as <code>int flags</code>, and in cases where code is being executed, it is passed as <code>PyCompilerFlags *flags</code>. In this case, <code>from
+__future__ import</code> can modify <em>flags</em>.</p> <p>Whenever <code>PyCompilerFlags *flags</code> is <code>NULL</code>, <a class="reference internal" href="#c.PyCompilerFlags.cf_flags" title="PyCompilerFlags.cf_flags"><code>cf_flags</code></a> is treated as equal to <code>0</code>, and any modification due to <code>from __future__ import</code> is discarded.</p> <dl class="c member"> <dt class="sig sig-object c" id="c.PyCompilerFlags.cf_flags">
+<code>int cf_flags</code> </dt> <dd>
+<p>Compiler flags.</p> </dd>
+</dl> <dl class="c member"> <dt class="sig sig-object c" id="c.PyCompilerFlags.cf_feature_version">
+<code>int cf_feature_version</code> </dt> <dd>
+<p><em>cf_feature_version</em> is the minor Python version. It should be initialized to <code>PY_MINOR_VERSION</code>.</p> <p>The field is ignored by default, it is used if and only if <code>PyCF_ONLY_AST</code> flag is set in <a class="reference internal" href="#c.PyCompilerFlags.cf_flags" title="PyCompilerFlags.cf_flags"><code>cf_flags</code></a>.</p> </dd>
+</dl> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.8: </span>Added <em>cf_feature_version</em> field.</p> </div> </dd>
+</dl> <dl class="c var"> <dt class="sig sig-object c" id="c.CO_FUTURE_DIVISION">
+<code>int CO_FUTURE_DIVISION</code> </dt> <dd>
+<p>This bit can be set in <em>flags</em> to cause division operator <code>/</code> to be interpreted as “true division” according to <span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-0238/"><strong>PEP 238</strong></a>.</p> </dd>
+</dl> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
+ <a href="https://docs.python.org/3.12/c-api/veryhigh.html" class="_attribution-link">https://docs.python.org/3.12/c-api/veryhigh.html</a>
+ </p>
+</div>