Skip to content

Commit bcb9164

Browse files
authored
[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 5def03d)
1 parent 706070c commit bcb9164

5 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎Doc/c-api/import.rst‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,11 @@ Importing Modules
265265
This is the structure type definition for frozen module descriptors, as
266266
generated by the :program:`freeze` utility (see :file:`Tools/freeze/` in the
267267
Python source distribution). Its definition, found in :file:`Include/import.h`,
268-
is::
269-
270-
struct _frozen {
271-
const char *name;
272-
const unsigned char *code;
273-
int size;
274-
bool is_package;
275-
};
268+
is:
269+
270+
.. literalinclude:: ../../Include/cpython/import.h
271+
:start-at: struct _frozen {
272+
:end-at: };
276273
277274
.. versionchanged:: 3.11
278275
The new ``is_package`` field indicates whether the module is a package or not.

‎Doc/c-api/typeobj.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ definition found there:
480480
.. XXX Drop this?
481481
482482
.. literalinclude:: ../includes/typestruct.h
483+
:end-at: } PyTypeObject;
483484

484485

485486
PyObject Slots

‎Doc/extending/newtypes.rst‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Here is the definition of :c:type:`PyTypeObject`, with some fields only used in
1515
:ref:`debug builds <debug-build>` omitted:
1616

1717
.. literalinclude:: ../includes/typestruct.h
18+
:end-at: } PyTypeObject;
1819

1920

2021
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::
285286
typedef struct PyMemberDef {
286287
const char *name;
287288
int type;
288-
int offset;
289+
Py_ssize_t offset;
289290
int flags;
290291
const char *doc;
291292
} PyMemberDef;

‎Doc/includes/typestruct.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,7 @@ typedef struct _typeobject {
9393
*/
9494
uint16_t tp_versions_used;
9595
} PyTypeObject;
96+
97+
/* Private fields are intentionally omitted.
98+
* Keep them excluded when updating this definition.
99+
*/

‎Include/cpython/import.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ struct _inittab {
1010
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
1111
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
1212

13+
/* This structure is included verbatim in the public documentation
14+
(Doc/c-api/import.rst). */
1315
struct _frozen {
1416
const char *name; /* ASCII encoded string */
1517
const unsigned char *code;

0 commit comments

Comments
 (0)