https://github.com/python/cpython/commit/bcb916430831284f1fb1a3bf392c72989310eaa7
commit: bcb916430831284f1fb1a3bf392c72989310eaa7
branch: 3.14
author: Nathan Goldbaum <[email protected]>
committer: ngoldbaum <[email protected]>
date: 2026-10-21T18:57:37Z
summary:

[3.14] gh-159808: Sync documented C API structs with their headers (GH-159812) 
(#160083)

The Doc/c-api/slots.rst change from the original commit is not included,
since that file and the PySlot struct only exist in 3.15.

(cherry picked from commit 5def03d7d647b24204aedac80baef17fed50579f)

files:
M Doc/c-api/import.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 369e95dd02251b4..bc2edf962930af2 100644
--- a/Doc/c-api/import.rst
+++ b/Doc/c-api/import.rst
@@ -265,14 +265,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/typeobj.rst b/Doc/c-api/typeobj.rst
index b8e2f19b50efafb..a8b8dee794e236e 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 e3612f3a1875cac..1627bbe1ab258be 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 0ce0b1ee6cce2a2..05d499488e33d1b 100644
--- a/Include/cpython/import.h
+++ b/Include/cpython/import.h
@@ -10,6 +10,8 @@ struct _inittab {
 PyAPI_DATA(struct _inittab *) PyImport_Inittab;
 PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
 
+/* 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]

Reply via email to