From 88ee59e60fd157c2ac22be8399e85a1643e03731 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 3 Aug 2026 16:54:31 +0200 Subject: [PATCH 1/2] gh-141004: Remove docs snippet that uses internal C API Follow-up to GH-143490. `_PyInterpreterFrame.f_executable` and `PyStackRef_AsPyObjectBorrow` are undocumented and only available in the internal API. Docs should not suggest using them, even if `PyUnstable_ExecutableKinds` is unusable without them. --- Doc/c-api/frame.rst | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/Doc/c-api/frame.rst b/Doc/c-api/frame.rst index a04ef4e422949b..3b17d84cfe9af5 100644 --- a/Doc/c-api/frame.rst +++ b/Doc/c-api/frame.rst @@ -269,29 +269,8 @@ Unless using :pep:`523`, you will not need this. * - .. c:macro:: PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR - The frame corresponds to a method on a class instance. - However, Python's C API lacks a function to read the executable kind from - a frame. Instead, use this recipe: - - .. code-block:: c - - int - get_executable_kind(PyFrameObject *frame) - { - _PyInterpreterFrame *f = frame->f_frame; - PyObject *exec = PyStackRef_AsPyObjectBorrow(f->f_executable); - - if (PyCode_Check(exec)) { - return PyUnstable_EXECUTABLE_KIND_PY_FUNCTION; - } - if (PyMethod_Check(exec)) { - return PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION; - } - if (Py_IS_TYPE(exec, &PyMethodDescr_Type)) { - return PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR; - } - - return PyUnstable_EXECUTABLE_KIND_SKIP; - } + Note that reading the executable kind from a frame is currently only + possible with undocumented internal API. .. versionadded:: 3.13 From 76359dd6ef2bebdb9e3c68124162c56edf22628f Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 4 Aug 2026 09:41:38 +0200 Subject: [PATCH 2/2] APIs Co-authored-by: Stan Ulbrych --- Doc/c-api/frame.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/frame.rst b/Doc/c-api/frame.rst index 3b17d84cfe9af5..70a610cea82d06 100644 --- a/Doc/c-api/frame.rst +++ b/Doc/c-api/frame.rst @@ -270,7 +270,7 @@ Unless using :pep:`523`, you will not need this. - The frame corresponds to a method on a class instance. Note that reading the executable kind from a frame is currently only - possible with undocumented internal API. + possible with undocumented internal APIs. .. versionadded:: 3.13