@@ -211,6 +211,71 @@ bound into a function.
211211 .. versionadded :: 3.12
212212
213213
214+ .. _c_codeobject_flags :
215+
216+ Code Object Flags
217+ -----------------
218+
219+ Code objects contain a bit-field of flags, which can be retrieved as the
220+ :attr: `~codeobject.co_flags ` Python attribute (for example using
221+ :c:func: `PyObject_GetAttrString `), and set using a *flags* argument to
222+ :c:func:`PyUnstable_Code_New` and similar functions.
223+
224+ Flags whose names start with ``CO_FUTURE_`` correspond to features normally
225+ selectable by :ref:`future statements <future>`. These flags can be used in
226+ :c:member:`PyCompilerFlags.cf_flags`.
227+ Note that many ``CO_FUTURE_`` flags are mandatory in current versions of
228+ Python, and setting them has no effect.
229+
230+ The following flags are available.
231+ For their meaning, see the linked documentation of their Python equivalents.
232+
233+
234+ .. list-table::
235+ :widths: auto
236+ :header-rows: 1
237+
238+ * * Flag
239+ * Meaning
240+ * * .. c:macro:: CO_OPTIMIZED
241+ * :py:data:`inspect.CO_OPTIMIZED`
242+ * * .. c:macro:: CO_NEWLOCALS
243+ * :py:data:`inspect.CO_NEWLOCALS`
244+ * * .. c:macro:: CO_VARARGS
245+ * :py:data:`inspect.CO_VARARGS`
246+ * * .. c:macro:: CO_VARKEYWORDS
247+ * :py:data:`inspect.CO_VARKEYWORDS`
248+ * * .. c:macro:: CO_NESTED
249+ * :py:data:`inspect.CO_NESTED`
250+ * * .. c:macro:: CO_GENERATOR
251+ * :py:data:`inspect.CO_GENERATOR`
252+ * * .. c:macro:: CO_COROUTINE
253+ * :py:data:`inspect.CO_COROUTINE`
254+ * * .. c:macro:: CO_ITERABLE_COROUTINE
255+ * :py:data:`inspect.CO_ITERABLE_COROUTINE`
256+ * * .. c:macro:: CO_ASYNC_GENERATOR
257+ * :py:data:`inspect.CO_ASYNC_GENERATOR`
258+ * * .. c:macro:: CO_HAS_DOCSTRING
259+ * :py:data:`inspect.CO_HAS_DOCSTRING`
260+ * * .. c:macro:: CO_METHOD
261+ * :py:data:`inspect.CO_METHOD`
262+
263+ * * .. c:macro:: CO_FUTURE_DIVISION
264+ * no effect (:py:data: `__future__.division `)
265+ * * .. c:macro:: CO_FUTURE_ABSOLUTE_IMPORT
266+ * no effect (:py:data: `__future__.absolute_import `)
267+ * * .. c:macro:: CO_FUTURE_WITH_STATEMENT
268+ * no effect (:py:data: `__future__.with_statement `)
269+ * * .. c:macro:: CO_FUTURE_PRINT_FUNCTION
270+ * no effect (:py:data: `__future__.print_function `)
271+ * * .. c:macro:: CO_FUTURE_UNICODE_LITERALS
272+ * no effect (:py:data: `__future__.unicode_literals `)
273+ * * .. c:macro:: CO_FUTURE_GENERATOR_STOP
274+ * no effect (:py:data: `__future__.generator_stop `)
275+ * * .. c:macro:: CO_FUTURE_ANNOTATIONS
276+ * :py:data:`__future__.annotations`
277+
278+
214279Extra information
215280-----------------
216281
0 commit comments