From d95447c30d29885f343da91d39ef080c3fa0d2d4 Mon Sep 17 00:00:00 2001 From: Aniket <148300120+Aniketsy@users.noreply.github.com> Date: Thu, 30 Jul 2026 18:18:38 +0530 Subject: [PATCH 1/3] [3.13] gh-151941: Fix Sphinx reference warnings in `Doc/c-api/` (GH-152044) (cherry picked from commit b3be16db02e71368774aab62c8ce3f6fb8cc5452) Co-authored-by: Aniket <148300120+Aniketsy@users.noreply.github.com> --- Doc/c-api/exceptions.rst | 15 +++++++++++++++ Doc/c-api/init_config.rst | 9 ++++----- Doc/c-api/intro.rst | 2 +- Doc/tools/.nitignore | 3 --- Tools/check-c-api-docs/ignored_c_api.txt | 5 ----- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index d66826d049820b..f41e2169cb80f3 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -119,6 +119,21 @@ Printing and clearing .. versionadded:: 3.12 +.. c:function:: void PyErr_Display(PyObject *unused, PyObject *value, PyObject *tb) + + Legacy variant of :c:func:`PyErr_DisplayException`. + + Print the exception *value* with its traceback to :data:`sys.stderr`. + If *value* has no traceback set, *tb* is used as its traceback. + The first argument is ignored. + + If :data:`sys.stderr` is ``None``, nothing is printed. + If :data:`sys.stderr` is not set, the exception is dumped to the + C ``stderr`` stream instead. + + .. deprecated:: 3.12 + Use :c:func:`PyErr_DisplayException` instead. + Raising exceptions ================== diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst index c34f1e03c875f7..7c4b319c98e4e0 100644 --- a/Doc/c-api/init_config.rst +++ b/Doc/c-api/init_config.rst @@ -610,9 +610,9 @@ PyConfig .. c:member:: wchar_t* base_executable - Python base executable: :data:`sys._base_executable`. + Python base executable: ``sys._base_executable``. - Set by the :envvar:`__PYVENV_LAUNCHER__` environment variable. + Set by the ``__PYVENV_LAUNCHER__`` environment variable. Set from :c:member:`PyConfig.executable` if ``NULL``. @@ -1093,7 +1093,7 @@ PyConfig * On macOS, use :envvar:`PYTHONEXECUTABLE` environment variable if set. * If the ``WITH_NEXT_FRAMEWORK`` macro is defined, use - :envvar:`__PYVENV_LAUNCHER__` environment variable if set. + ``__PYVENV_LAUNCHER__`` environment variable if set. * Use ``argv[0]`` of :c:member:`~PyConfig.argv` if available and non-empty. * Otherwise, use ``L"python"`` on Windows, or ``L"python3"`` on other @@ -1304,8 +1304,7 @@ PyConfig The :mod:`warnings` module adds :data:`sys.warnoptions` in the reverse order: the last :c:member:`PyConfig.warnoptions` item becomes the first - item of :data:`warnings.filters` which is checked first (highest - priority). + item of ``warnings.filters`` which is checked first (highest priority). The :option:`-W` command line options adds its value to :c:member:`~PyConfig.warnoptions`, it can be used multiple times. diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index 2d3360a5a3bd92..b09821cb38aa3d 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -1024,7 +1024,7 @@ in the Unix build, compiler optimization is disabled. In addition to the reference count debugging described below, extra checks are performed, see :ref:`Python Debug Build `. -Defining :c:macro:`Py_TRACE_REFS` enables reference tracing +Defining ``Py_TRACE_REFS`` enables reference tracing (see the :option:`configure --with-trace-refs option <--with-trace-refs>`). When defined, a circular doubly linked list of active objects is maintained by adding two extra fields to every :c:type:`PyObject`. Total allocations are tracked as well. Upon diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index bb701c3a7be86c..a6495dc3cc5ad9 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -3,10 +3,7 @@ # Keep lines sorted lexicographically to help avoid merge conflicts. Doc/c-api/float.rst -Doc/c-api/init_config.rst -Doc/c-api/intro.rst Doc/c-api/module.rst -Doc/c-api/stable.rst Doc/library/ast.rst Doc/library/asyncio-extending.rst Doc/library/asyncio-policy.rst diff --git a/Tools/check-c-api-docs/ignored_c_api.txt b/Tools/check-c-api-docs/ignored_c_api.txt index abb61a972129d2..65e5ca539217cb 100644 --- a/Tools/check-c-api-docs/ignored_c_api.txt +++ b/Tools/check-c-api-docs/ignored_c_api.txt @@ -62,11 +62,6 @@ PyStdPrinter_Type Py_UniversalNewlineFgets # cpython/pylifecycle.h Py_FrozenMain -# cpython/unicodeobject.h -PyUnicode_IS_COMPACT -PyUnicode_IS_COMPACT_ASCII -# pythonrun.h -PyErr_Display # cpython/objimpl.h PyObject_GET_WEAKREFS_LISTPTR # cpython/pythonrun.h From 5788d5a492711863a25357a74406e1058f2ae8dc Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 30 Jul 2026 08:58:37 -0400 Subject: [PATCH 2/3] Removed too many things oops. --- Tools/check-c-api-docs/ignored_c_api.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tools/check-c-api-docs/ignored_c_api.txt b/Tools/check-c-api-docs/ignored_c_api.txt index 65e5ca539217cb..c74fbcfbb063bb 100644 --- a/Tools/check-c-api-docs/ignored_c_api.txt +++ b/Tools/check-c-api-docs/ignored_c_api.txt @@ -62,6 +62,9 @@ PyStdPrinter_Type Py_UniversalNewlineFgets # cpython/pylifecycle.h Py_FrozenMain +# cpython/unicodeobject.h +PyUnicode_IS_COMPACT +PyUnicode_IS_COMPACT_ASCII # cpython/objimpl.h PyObject_GET_WEAKREFS_LISTPTR # cpython/pythonrun.h From 7b5c8533a6da01085a128893df8961921c76ca5b Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 30 Jul 2026 09:04:55 -0400 Subject: [PATCH 3/3] Fix 3.13 quirks. --- Doc/c-api/init_config.rst | 2 +- Doc/c-api/intro.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst index 7c4b319c98e4e0..7053b53537c555 100644 --- a/Doc/c-api/init_config.rst +++ b/Doc/c-api/init_config.rst @@ -1620,7 +1620,7 @@ initialization, the core feature of :pep:`432`: Private provisional API: -* :c:member:`PyConfig._init_main`: if set to ``0``, +* ``PyConfig._init_main``: if set to ``0``, :c:func:`Py_InitializeFromConfig` stops at the "Core" initialization phase. .. c:function:: PyStatus _Py_InitializeMain(void) diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index b09821cb38aa3d..0259d809c6cbe7 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -337,7 +337,7 @@ complete listing. implemented with ``__builtin_unreachable()`` on GCC in release mode. A use for ``Py_UNREACHABLE()`` is following a call to a function that - never returns but that is not declared :c:macro:`_Py_NO_RETURN`. + never returns but that is not declared ``_Py_NO_RETURN``. If a code path is very unlikely code but can be reached under exceptional case, this macro must not be used. For example, under low memory condition