Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-47115: Document which parts of structs are in limited API/stable ABI#32196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
encukou commented Mar 30, 2022 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
arhadthedev commented Mar 30, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
A side question since |
| opaque | ||
| struct PyFrameObject | ||
| added 3.2 | ||
| opaque |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, I recently added "The structure is not part of the C API." to:
https://docs.python.org/dev/c-api/frame.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's wrong. If it's not part of the API at all, you can't use functions like PyFrame_GetBack that take it as an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like there is a misunderstanding on what "a structure" means here. Python C API is misleading because it uses short PyFrameObject type name rather than struct PyFrameObject.
In practice in C, "PyFrameObject" is a type name, not a structure. I recently added Include/pytypedefs.h to clarify which type names are always available in the C API (and fix a compiler error), even if their related structures are opaque. I understand that the type (type "name") is part of the C API, but the structure is not.
I'm not sure how https://docs.python.org/dev/c-api/frame.html should be rephrased. The follow this PR, maybe "The structure is opaque" which may become redundant once this PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see.
This should be explained/avoided: if you don't know the term "opaque structure" you are likely to search for it, but if you don't realize the distinction between "type" and "structure", you'll probably just be confused.
I'll work on the rephrasing next week. Please let me know if you know of other places with similar wording.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started going through all the structs to make sure the docs make sense.
And I quite like the note for PyInterpreterState: “There are no public members in this structure.” Short and clear! I'll use that for PyFrameObject too.
vstinner commented Mar 30, 2022
Is there a definition of an "opaque structure" in the Python doc? Is there a link from "opaque struct" in then generated doc? |
encukou commented Mar 30, 2022
IMO it's a generally known term, it even has a Wikipedia entry. I don't think the docs need to define it. |
encukou commented Mar 30, 2022
@arhadthedev, I'll open an issue for it. |
encukou commented Mar 30, 2022
Issue for the renaming (and more): https://bugs.python.org/issue47168 |
erlend-aasland left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice; I think this doc enhancement will be helpful for both core devs and others.
From what I could see, the Py changes look sensible, but I'm not at all familiar with these doc tools. I'll have another look at this tomorrow.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
encukou commented Apr 1, 2022
vstinner commented Apr 1, 2022
“There are no public members in this structure.” That's explicit. It prevents the confusion about "the structure is not part of the C API" and confusion between "structure" and "type". In practice, an opaque structure ... is an empty structure, right ;-) The only subtle difference is that sizeof() doesn't work on an opaque structure, but I don't think that it's worth it to do into the details, unless we add an entry to the glossary for "opaque structure". |
vstinner left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
erlend-aasland left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me also.
It looks to me that this comment is now outdated:
cpython/Doc/tools/extensions/c_annotations.py
Lines 101 to 103 in 4b188ae
| # Stable ABI annotation. These have two forms: | |
| # Part of the [Stable ABI](link). | |
| # Part of the [Stable ABI](link) since version X.Y. |
Either update it or delete it :)
encukou commented Apr 6, 2022
…ABI (pythonGH-32196) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>


Some screenshots of the result:
Opaque struct:





Fully visible structs:
Partial struct (see the issue for details):
Included member of the above:
Non-struct items don't change:

https://bugs.python.org/issue47115