Skip to content

Documentation about PyTypeObject being part of the Stable ABI #95300

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

Closed
ov2k opened this issue Jul 26, 2022 · 10 comments · Fixed by #95711
Closed

Documentation about PyTypeObject being part of the Stable ABI #95300

ov2k opened this issue Jul 26, 2022 · 10 comments · Fixed by #95711
Labels
docs Documentation in the Doc dir topic-C-API triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error

Comments

@ov2k
Copy link
Contributor

ov2k commented Jul 26, 2022

https://docs.python.org/3/c-api/typeobj.html#static-types says:

Also, since PyTypeObject is not part of the stable ABI, any extension modules using static types must be compiled for a specific Python minor version.

https://docs.python.org/3/c-api/type.html#c.PyTypeObject says:

Part of the Stable ABI.

I'm not sure what needs to be fixed, but something does. Can extension modules using the Stable ABI use static types now?

@ov2k ov2k changed the title Documentation about PyTypeObject being part of the stable ABI Documentation about PyTypeObject being part of the Stable ABI Jul 26, 2022
@erlend-aasland erlend-aasland added topic-C-API docs Documentation in the Doc dir triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error labels Jul 26, 2022
@erlend-aasland
Copy link
Contributor

The former quote should probably read Limited API, not Stable ABI. cc. @encukou

@kumaraditya303
Copy link
Contributor

Technically PyTypeObject is part of the stable ABI as an opaque struct (whose fields are part of the ABI) because stable ABI uses Limited C API. Maybe it's better to just document it as "part of Limited C API as an opaque struct".

@encukou
Copy link
Member

encukou commented Jul 27, 2022

This is fixed in https://docs.python.org/3.11/c-api/type.html#c.PyTypeObject
But it would make sense to backport to earlier docs.

@encukou
Copy link
Member

encukou commented Aug 5, 2022

PR is at #95711

@ov2k
Copy link
Contributor Author

ov2k commented Aug 5, 2022

I think https://docs.python.org/3/c-api/typeobj.html#static-types still needs to be fixed. https://docs.python.org/3/c-api/stable.html says:

Extensions that only use the Limited API can be compiled once and work with multiple versions of Python.

It's not that PyTypeObject isn't part of the Stable ABI, but that its members aren't part of the Limited API.

@encukou
Copy link
Member

encukou commented Aug 8, 2022

It's both.
In the limited API/stable ABI, PyTypeObject is opaque (and has been since the beginning). The ABI for an opaque struct is just a pointer, so there's nothing specific to PyTypeObject in the Stable ABI.

(The first part of PyTypeObject happens to be stable across releases, but that's because it's needed for declarations without designated initializers using the regular C- API.)

@erlend-aasland
Copy link
Contributor

Suggesting to close this as fixed.

@erlend-aasland erlend-aasland added the pending The issue will be closed if no feedback is provided label Aug 8, 2022
@encukou
Copy link
Member

encukou commented Aug 8, 2022

@ov2k, please feel free to comment if you disagree, have other suggestions, or if something is unclear.
(Not sure if you have permission to reopen – if you do, that's also an option.)

@encukou encukou closed this as completed Aug 8, 2022
@erlend-aasland erlend-aasland removed the pending The issue will be closed if no feedback is provided label Aug 8, 2022
@ov2k
Copy link
Contributor Author

ov2k commented Aug 11, 2022

That's exactly my point, but perhaps I wasn't being clear enough. https://docs.python.org/3/c-api/typeobj.html#static-types makes no reference to PyTypeObject being opaque, which is the real reason why extension modules using static types must be compiled for a specific Python minor version. It should say something like:

Also, since PyTypeObject is only part of the Limited API as an opaque struct...

@encukou
Copy link
Member

encukou commented Aug 17, 2022

It makes sense to me, but I've been thinking about API/ABI way too much :)
Could you send a PR to make this clearer? If not I'll get to it eventually.

@encukou encukou reopened this Aug 17, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 25, 2022
…ythonGH-96217)

Fixes:
python#95300

Related:
python#91271
(cherry picked from commit caa2a97)

Co-authored-by: ov2k <ov2k.github@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 25, 2022
…ythonGH-96217)

Fixes:
python#95300

Related:
python#91271
(cherry picked from commit caa2a97)

Co-authored-by: ov2k <ov2k.github@gmail.com>
miss-islington added a commit that referenced this issue Aug 25, 2022
…H-96217)

Fixes:
#95300

Related:
#91271
(cherry picked from commit caa2a97)

Co-authored-by: ov2k <ov2k.github@gmail.com>
miss-islington added a commit that referenced this issue Aug 25, 2022
…H-96217)

Fixes:
#95300

Related:
#91271
(cherry picked from commit caa2a97)

Co-authored-by: ov2k <ov2k.github@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 topic-C-API triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error
Projects
None yet
4 participants