https://github.com/python/cpython/commit/3d92906b9b6d4fccfac4dab0a60b89176851c5d6 commit: 3d92906b9b6d4fccfac4dab0a60b89176851c5d6 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: ngoldbaum <[email protected]> date: 2026-10-21T18:17:16Z summary:
[3.15] gh-159808: Sync documented C API structs with their headers (GH-159812) (#160074) gh-159808: Sync documented C API structs with their headers (GH-159812) (cherry picked from commit 5def03d7d647b24204aedac80baef17fed50579f) Co-authored-by: Nathan Goldbaum <[email protected]> files: M Doc/c-api/import.rst M Doc/c-api/slots.rst M Doc/c-api/typeobj.rst M Doc/extending/newtypes.rst M Doc/includes/typestruct.h M Include/cpython/import.h diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst index f1f3c455c94c798..2eb8a45d299bc6c 100644 --- a/Doc/c-api/import.rst +++ b/Doc/c-api/import.rst @@ -257,14 +257,11 @@ Importing Modules This is the structure type definition for frozen module descriptors, as generated by the :program:`freeze` utility (see :file:`Tools/freeze/` in the Python source distribution). Its definition, found in :file:`Include/import.h`, - is:: - - struct _frozen { - const char *name; - const unsigned char *code; - int size; - bool is_package; - }; + is: + + .. literalinclude:: ../../Include/cpython/import.h + :start-at: struct _frozen { + :end-at: }; .. versionchanged:: 3.11 The new ``is_package`` field indicates whether the module is a package or not. diff --git a/Doc/c-api/slots.rst b/Doc/c-api/slots.rst index 84a125cb60bae7e..8472e8130feca16 100644 --- a/Doc/c-api/slots.rst +++ b/Doc/c-api/slots.rst @@ -48,7 +48,9 @@ Entries of the slots array use the following structure: typedef struct { uint16_t sl_id; uint16_t sl_flags; - uint32_t _reserved; // must be 0 + union { + uint32_t sl_reserved; // must be 0 + }; union { void *sl_ptr; void (*sl_func)(void); diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 72d8f97b67e4d05..ee6df73a105d85e 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -480,6 +480,7 @@ definition found there: .. XXX Drop this? .. literalinclude:: ../includes/typestruct.h + :end-at: } PyTypeObject; PyObject Slots diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst index 26085b5cebd3add..cb0b66ce0fc77b6 100644 --- a/Doc/extending/newtypes.rst +++ b/Doc/extending/newtypes.rst @@ -15,6 +15,7 @@ Here is the definition of :c:type:`PyTypeObject`, with some fields only used in :ref:`debug builds <debug-build>` omitted: .. literalinclude:: ../includes/typestruct.h + :end-at: } PyTypeObject; Now that's a *lot* of methods. Don't worry too much though -- if you have @@ -285,7 +286,7 @@ be read-only or read-write. The structures in the table are defined as:: typedef struct PyMemberDef { const char *name; int type; - int offset; + Py_ssize_t offset; int flags; const char *doc; } PyMemberDef; diff --git a/Doc/includes/typestruct.h b/Doc/includes/typestruct.h index 0d1d85ce9741b28..7ccd0297c3bffd5 100644 --- a/Doc/includes/typestruct.h +++ b/Doc/includes/typestruct.h @@ -93,3 +93,7 @@ typedef struct _typeobject { */ uint16_t tp_versions_used; } PyTypeObject; + +/* Private fields are intentionally omitted. + * Keep them excluded when updating this definition. + */ diff --git a/Include/cpython/import.h b/Include/cpython/import.h index 149a20af8b9cbb2..d326d6b119f9003 100644 --- a/Include/cpython/import.h +++ b/Include/cpython/import.h @@ -17,6 +17,8 @@ PyAPI_FUNC(PyObject *) PyImport_CreateModuleFromInitfunc( PyObject *spec, PyObject *(*initfunc)(void)); +/* This structure is included verbatim in the public documentation + (Doc/c-api/import.rst). */ struct _frozen { const char *name; /* ASCII encoded string */ const unsigned char *code; _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
