Skip to content

gh-141004: Document unstable executable kind macros in pyframe.h#143490

Merged
ZeroIntensity merged 19 commits into
python:mainfrom
Yashp002:doc-pyframe-unstable
Jul 18, 2026
Merged

gh-141004: Document unstable executable kind macros in pyframe.h#143490
ZeroIntensity merged 19 commits into
python:mainfrom
Yashp002:doc-pyframe-unstable

Conversation

@Yashp002

@Yashp002 Yashp002 commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

gh-141004: Document unstable executable kind macros in pyframe.h

This PR documents the PyUnstable_EXECUTABLE_KIND_* macros and the PyUnstable_ExecutableKinds array in Doc/c-api/frame.rst. These were listed as undocumented in the parent issue.


📚 Documentation preview 📚: https://cpython-previews--143490.org.readthedocs.build/

@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Jan 6, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Jan 6, 2026
Comment thread Doc/c-api/frame.rst Outdated
Index for the "skip" kind in ``PyUnstable_ExecutableKinds``.
Indicates that the frame's code object should be skipped.

.. versionadded:: 3.12

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9c03215 was not backported to 3.12?

@encukou

encukou commented Jan 7, 2026

Copy link
Copy Markdown
Member

These are rather useless without docs for PyUnstable_ExecutableKinds.
Once you document that, you can associate the macros with it, like for example Py_MOD_GIL_USED with Py_mod_gil.

@Yashp002

Yashp002 commented Jan 7, 2026

Copy link
Copy Markdown
Contributor Author

@encukou ok, makes sense. I'll add the documentation for PyUnstable_ExecutableKinds and link these macros to it. Thanks :)

Comment thread Doc/c-api/frame.rst Outdated
Comment on lines +255 to +257
An enumeration of the different kinds of executables (code objects) in a frame.
This can be one of the constants :c:macro:`PyUnstable_EXECUTABLE_KIND_SKIP`
or :c:macro:`PyUnstable_EXECUTABLE_KIND_PY_FUNCTION`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an array, not an enum.
Could you document what it's useful for or how to use it? That part isn't very clear to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go through what i've mentioned below and let me know if its perfectly appropriate, and as soon I recieve the heads up i'll update and commit:

.. c:var:: PyUnstable_ExecutableKinds

An array of executable kinds (executor types) for frames, used for internal
debugging and tracing. The entries are indexed by the constants
:c:macro:PyUnstable_EXECUTABLE_KIND_SKIP or
:c:macro:PyUnstable_EXECUTABLE_KIND_PY_FUNCTION.

This can be used to identify the type of the code object associated with a frame.

.. versionadded:: 3.13

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could @encukou or @StanFromIreland please review my suggestion above and correct it if its wrong or gimme the green light to commit this ⬆️

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer some words on why/how you'd use this.

You can say “The entries are indexed by the following constants:”, and indent the docs for the constants. Since the entries are all similar, you could even use a compact table, like in code object flags.

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to update ignored_c_api.txt here too.

Comment thread Doc/c-api/frame.rst Outdated
Comment on lines +296 to +298



Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many blank lines.

Comment thread Doc/c-api/frame.rst Outdated

.. c:macro:: PyUnstable_EXECUTABLE_KIND_PY_FUNCTION

Index for the "Python function" kind in ``PyUnstable_ExecutableKinds``.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be links via :c:data:`PyUnstable_ExecutableKinds`

@Yashp002

Yashp002 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

test_asyncio.test_sendfile port conflict - unrelated to docs.

@StanFromIreland

StanFromIreland commented Jan 8, 2026

Copy link
Copy Markdown
Member

We don't need those tests to run at all really, we can (I think) exclude the ignore file from triggering the run-tests condition.

Edit: See #143583.

@Yashp002

Yashp002 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

We don't need those tests to run at all really, we can (I think) exclude the ignore file from triggering the run-tests condition.

Edit: See #143583.

Can the same be said for #143492
and #143494 then? @StanFromIreland

@Yashp002

Copy link
Copy Markdown
Contributor Author

@StanFromIreland @encukou Here too, do I need to make any more changes?

@encukou

encukou commented Jan 19, 2026

Copy link
Copy Markdown
Member

This part is not clear to me:

Tools like debuggers and profilers can use this to identify the type of execution
context associated with a frame (e.g. to filter out internal frames).

I assume “frame” refers to PyFrameObject?
How do you use this array to filter out internal frames?


Once the docs say what the function is for and how to use it, there are some presentation issues to fix up:

There are now two descriptions for PyUnstable_EXECUTABLE_KIND_SKIP: on in list-table and one below. Choose one. If you need a full/sentence, use individual entries; if you only need a few words then the table makes sense.
Either way, indent the macro docs so they're under PyUnstable_ExecutableKinds, and use .. c:namespace:: NULL (see elsewhere in the docs for examples).

@Yashp002

Copy link
Copy Markdown
Contributor Author

@encukou Since PyUnstable_EXECUTABLE_KIND_SKIP has only a couple words, should I just keep the list-table description and remove the one below completely?
image
as in the description of it below.

Also, Yes the frame refers to PyFrameObject and I'll be adding a sentence below saying "The frame should be skipped by tools.
- The frame corresponds to a standard Py function"

    Also, to check for internal frames:
    perf_map = PyUnstable_GetPerfMapFile()
    for i, kind in enumerate(perf_map):
       if kind == PyUnstable_EXECUTABLE_KIND_SKIP:
          skip_frame(i) 
          
          It's from the Cpython source code

Should i go ahead with above mentioned changes?
Also, my indents with c:macro: are fine right? or have i missed something

@encukou

encukou commented Jan 22, 2026

Copy link
Copy Markdown
Member

Since PyUnstable_EXECUTABLE_KIND_SKIP has only a couple words, should I just keep the list-table description and remove the one below completely?

Yes. But switch to the .. c:macro: syntax rather than :c:macro:, so this is a definition.

Example code would be very helpful, yes. Please test that it works, though.

Comment thread Doc/c-api/frame.rst Outdated
debugging and tracing.

Tools like debuggers and profilers can use this to identify the type of execution
context associated with a frame (e.g. to filter out internal frames).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use latin abbreviations, see our style guide for more information.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you mentioned this before, I'm sorry it slipped my mind, fixing now.

Comment thread Doc/c-api/frame.rst Outdated
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_PY_FUNCTION
- The frame corresponds to a standard Python function.

.. versionadded:: 3.13

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .. versionadded:: ... should be the last thing in a function's/macro's/type's/etc. doc, please move it after the example.

Comment thread Doc/c-api/frame.rst Outdated
.. code-block:: c

// Check if a frame should be skipped
if (kind == PyUnstable_EXECUTABLE_KIND_SKIP) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is kind? How do you get it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@encukou kind here refers to the executable kind field stored in the frame's executor (e.g. _PyFrame_GetExecutableKind(frame))
Do you think it's better to explicitly show _PyFrame_GetExecutableKind (if exposed), or should I just remove the example block to avoid confusion?

@encukou encukou Feb 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, explicitly show your _PyFrame_GetExecutableKind. We'll also need to make it public (or at least unstable) if we want users to use it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there's no API for getting kind. The only way to get the right thing is to check the type, but at that point, you don't need PyUnstable_ExecutableKinds anyway (because the whole point of it is that you're not supposed to know the type in advance). This API is quite literally useless. I think we should remove it in 3.16, but for completeness, I want this documented in 3.13+.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jul 4, 2026
@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 18, 2026

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge this for completeness. If we decide to remove this (see #152105), we can remove only the docs for 3.16.

@ZeroIntensity
ZeroIntensity enabled auto-merge (squash) July 18, 2026 14:47
@ZeroIntensity
ZeroIntensity merged commit dc62ba8 into python:main Jul 18, 2026
69 of 72 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jul 18, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @Yashp002 for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @Yashp002 and @ZeroIntensity, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker dc62ba84ab2b83d70dee111d3feec1a6f1c3f69d 3.14

@bedevere-app

bedevere-app Bot commented Jul 18, 2026

Copy link
Copy Markdown

GH-153988 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 18, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @Yashp002 and @ZeroIntensity, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker dc62ba84ab2b83d70dee111d3feec1a6f1c3f69d 3.13

@bedevere-app

bedevere-app Bot commented Jul 18, 2026

Copy link
Copy Markdown

GH-153991 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 18, 2026
@bedevere-app

bedevere-app Bot commented Jul 18, 2026

Copy link
Copy Markdown

GH-153993 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 18, 2026
ZeroIntensity added a commit that referenced this pull request Jul 18, 2026
…ame.h` (GH-143490) (GH-153988)

(cherry picked from commit dc62ba8)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
ZeroIntensity added a commit that referenced this pull request Jul 18, 2026
…ame.h` (GH-143490) (GH-153991)

(cherry picked from commit dc62ba8)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
ZeroIntensity added a commit that referenced this pull request Jul 18, 2026
…ame.h` (GH-143490) (GH-153993)

(cherry picked from commit dc62ba8)

Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants