FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-159808: Sync documented C API structs with their headers by ngoldbaum · Pull Request #159812 · python/cpython · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .h  (2) .rst  (4) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 5 additions & 8 deletions Doc/c-api/import.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Could you add a comment to import.h before the struct, warning that this is included in public docs?

:start-at: struct _frozen {
:end-at: };

.. versionchanged:: 3.11
The new ``is_package`` field indicates whether the module is a package or not.
Expand Down
4 changes: 3 additions & 1 deletion Doc/c-api/slots.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Doc/c-api/typeobj.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ definition found there:
.. XXX Drop this?

.. literalinclude:: ../includes/typestruct.h
:end-at: } PyTypeObject;


PyObject Slots
Expand Down
3 changes: 2 additions & 1 deletion Doc/extending/newtypes.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Doc/includes/typestruct.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
2 changes: 2 additions & 0 deletions Include/cpython/import.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

Back | FazBrowse Home | New Git URL