@@ -13,8 +13,9 @@ the interpreter.
1313
1414Several of these functions accept a start symbol from the grammar as a
1515parameter. The available start symbols are :c:data: `Py_eval_input `,
16- :c:data: `Py_file_input `, and :c:data: `Py_single_input `. These are described
17- following the functions which accept them as parameters.
16+ :c:data: `Py_file_input `, :c:data: `Py_single_input `, and
17+ :c:data: `Py_func_type_input `. These are described following the functions
18+ which accept them as parameters.
1819
1920Note also that several of these functions take :c:expr: `FILE* ` parameters. One
2021particular issue which needs to be handled carefully is that the :c:type: `FILE `
@@ -183,8 +184,7 @@ the same library that the Python runtime is using.
183184 objects *globals * and *locals * with the compiler flags specified by
184185 *flags *. *globals * must be a dictionary; *locals * can be any object
185186 that implements the mapping protocol. The parameter *start * specifies
186- the start symbol and must one of the following:
187- :c:data: `Py_eval_input `, :c:data: `Py_file_input `, or :c:data: `Py_single_input `.
187+ the start symbol and must one of the :ref: `available start symbols <start-symbols >`.
188188
189189 Returns the result of executing the code as a Python object, or ``NULL `` if an
190190 exception was raised.
@@ -233,11 +233,10 @@ the same library that the Python runtime is using.
233233
234234 Parse and compile the Python source code in *str *, returning the resulting code
235235 object. The start symbol is given by *start *; this can be used to constrain the
236- code which can be compiled and should be :c:data: `Py_eval_input `,
237- :c:data: `Py_file_input `, or :c:data: `Py_single_input `. The filename specified by
238- *filename * is used to construct the code object and may appear in tracebacks or
239- :exc: `SyntaxError ` exception messages. This returns ``NULL `` if the code
240- cannot be parsed or compiled.
236+ code which can be compiled and should be one of the :ref: `available start symbols <start-symbols >`.
237+ The filename specified by *filename * is used to construct the code object
238+ and may appear in tracebacks or :exc: `SyntaxError ` exception messages.
239+ This returns ``NULL `` if the code cannot be parsed or compiled.
241240
242241 The integer *optimize * specifies the optimization level of the compiler; a
243242 value of ``-1 `` selects the optimization level of the interpreter as given by
@@ -297,32 +296,6 @@ the same library that the Python runtime is using.
297296 true on success, false on failure.
298297
299298
300- .. c :var :: int Py_eval_input
301-
302- .. index :: single: Py_CompileString (C function)
303-
304- The start symbol from the Python grammar for isolated expressions; for use with
305- :c:func: `Py_CompileString `.
306-
307-
308- .. c :var :: int Py_file_input
309-
310- .. index :: single: Py_CompileString (C function)
311-
312- The start symbol from the Python grammar for sequences of statements as read
313- from a file or other source; for use with :c:func: `Py_CompileString `. This is
314- the symbol to use when compiling arbitrarily long Python source code.
315-
316-
317- .. c :var :: int Py_single_input
318-
319- .. index :: single: Py_CompileString (C function)
320-
321- The start symbol from the Python grammar for a single statement; for use with
322- :c:func: `Py_CompileString `. This is the symbol used for the interactive
323- interpreter loop.
324-
325-
326299.. c :struct :: PyCompilerFlags
327300
328301 This is the structure used to hold compiler flags. In cases where code is only
@@ -366,3 +339,50 @@ the same library that the Python runtime is using.
366339 as :c:macro: `CO_FUTURE_ANNOTATIONS ` to enable features normally
367340 selectable using :ref: `future statements <future >`.
368341 See :ref: `c_codeobject_flags ` for a complete list.
342+
343+
344+ .. _start-symbols :
345+
346+ Available start symbols
347+ ^^^^^^^^^^^^^^^^^^^^^^^
348+
349+
350+ .. c :var :: int Py_eval_input
351+
352+ .. index :: single: Py_CompileString (C function)
353+
354+ The start symbol from the Python grammar for isolated expressions; for use with
355+ :c:func: `Py_CompileString `.
356+
357+
358+ .. c :var :: int Py_file_input
359+
360+ .. index :: single: Py_CompileString (C function)
361+
362+ The start symbol from the Python grammar for sequences of statements as read
363+ from a file or other source; for use with :c:func: `Py_CompileString `. This is
364+ the symbol to use when compiling arbitrarily long Python source code.
365+
366+
367+ .. c :var :: int Py_single_input
368+
369+ .. index :: single: Py_CompileString (C function)
370+
371+ The start symbol from the Python grammar for a single statement; for use with
372+ :c:func: `Py_CompileString `. This is the symbol used for the interactive
373+ interpreter loop.
374+
375+
376+ .. c :var :: int Py_func_type_input
377+
378+ .. index :: single: Py_CompileString (C function)
379+
380+ The start symbol from the Python grammar for a function type; for use with
381+ :c:func: `Py_CompileString `. This is used for parsing function ``# type: ``
382+ comments.
383+
384+ This requires the :c:macro: `PyCF_ONLY_AST ` flag to be set.
385+
386+ .. seealso ::
387+ :py:class: `ast.FunctionType `
388+
0 commit comments