Repository navigation
docs: Correct ctypes examples and outdated descriptions - #161303
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the ctypes documentation updates.
No open issues 🎉
What changed in this PR
This documentation-only PR updates the ctypes reference to correct examples and align descriptions with current behavior.
Changes:
- Fix example output, shared-memory pointer assignments, and anonymous-union construction.
- Update frozen-module structure definitions and explanations.
- Clarify alignment, argument and return conversions, type codes, field finalization, and bitfield extraction.
| File | Description |
|---|---|
Doc/library/ctypes.rst |
Corrects runnable examples, outdated API descriptions, and documentation errors. |
Review effort: Balanced
Documentation build overview
|
ZeroIntensity
approved these changes
Nov 4, 2026
|
Thanks @methane for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
GH-161312 is a backport of this pull request to the 3.15 branch. |
|
GH-161313 is a backport of this pull request to the 3.14 branch. |
methane
added a commit
that referenced
this pull request
Nov 4, 2026
(cherry picked from commit 6fa6d09) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
methane
added a commit
that referenced
this pull request
Nov 4, 2026
(cherry picked from commit 6fa6d09) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello, Worldso the output matches the input string._align_specifies a minimum alignment; the previous wording incorrectly described it as a maximum..contentsraisesTypeError, while indexing updates the shared memory._PyImport_FrozenBootstraptable used by the example, and update the structure definition and package detection to useis_package.c_char_pargument conversion description: it accepts bytes and does not implicitly encodestr.'L'with'q';'L'is used byc_ulong.TYPEDESCand assigning pointer instances rather than pointer types.bit_offset.c_char_preturn value becomesNonefor a NULL pointer, and remove the obsolete Unicode-return comment.sizeof()from the operations that finalize_fields_; querying the size does not prevent subsequent field assignment.