From fb44e8aa77ea938d97cbce7894308991e6a1d1dd Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sun, 19 Jan 2025 12:37:42 -0500 Subject: [PATCH 1/2] C API: Document compiler flag macros --- Doc/c-api/veryhigh.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst index 9f02bdb5896563..0c69d98494f7d3 100644 --- a/Doc/c-api/veryhigh.rst +++ b/Doc/c-api/veryhigh.rst @@ -333,6 +333,8 @@ the same library that the Python runtime is using. equal to ``0``, and any modification due to ``from __future__ import`` is discarded. + The available :ref:`compiler flags ` are accessible as macros. + .. c:member:: int cf_flags Compiler flags. @@ -348,6 +350,21 @@ the same library that the Python runtime is using. .. versionchanged:: 3.8 Added *cf_feature_version* field. +.. c:macro:: PyCF_ALLOW_TOP_LEVEL_AWAIT + + Equivalent to :data:`ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`. + +.. c:macro:: PyCF_ONLY_AST + + Equivalent to :data:`ast.PyCF_ONLY_AST`. + +.. c:macro:: PyCF_OPTIMIZED_AST + + Equivalent to :data:`ast.PyCF_OPTIMIZED_AST`. + +.. c:macro:: PyCF_TYPE_COMMENTS + + Equivalent to :data:`ast.PyCF_TYPE_COMMENTS`. .. c:var:: int CO_FUTURE_DIVISION From 8709a4d456b34e3b19520577dd3adcb405116860 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 20 Jan 2025 10:44:19 +0100 Subject: [PATCH 2/2] Reorganize compiler flag docs --- Doc/c-api/veryhigh.rst | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst index 0c69d98494f7d3..1ef4181d52eb10 100644 --- a/Doc/c-api/veryhigh.rst +++ b/Doc/c-api/veryhigh.rst @@ -333,8 +333,6 @@ the same library that the Python runtime is using. equal to ``0``, and any modification due to ``from __future__ import`` is discarded. - The available :ref:`compiler flags ` are accessible as macros. - .. c:member:: int cf_flags Compiler flags. @@ -350,23 +348,20 @@ the same library that the Python runtime is using. .. versionchanged:: 3.8 Added *cf_feature_version* field. -.. c:macro:: PyCF_ALLOW_TOP_LEVEL_AWAIT - - Equivalent to :data:`ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`. - -.. c:macro:: PyCF_ONLY_AST - - Equivalent to :data:`ast.PyCF_ONLY_AST`. - -.. c:macro:: PyCF_OPTIMIZED_AST + The available compiler flags are accessible as macros: - Equivalent to :data:`ast.PyCF_OPTIMIZED_AST`. + .. c:namespace:: NULL -.. c:macro:: PyCF_TYPE_COMMENTS + .. c:macro:: PyCF_ALLOW_TOP_LEVEL_AWAIT + PyCF_ONLY_AST + PyCF_OPTIMIZED_AST + PyCF_TYPE_COMMENTS - Equivalent to :data:`ast.PyCF_TYPE_COMMENTS`. + See :ref:`compiler flags ` in documentation of the + :py:mod:`!ast` Python module, which exports these constants under + the same names. -.. c:var:: int CO_FUTURE_DIVISION + .. c:var:: int CO_FUTURE_DIVISION - This bit can be set in *flags* to cause division operator ``/`` to be - interpreted as "true division" according to :pep:`238`. + This bit can be set in *flags* to cause division operator ``/`` to be + interpreted as "true division" according to :pep:`238`.