https://github.com/python/cpython/commit/092c89667d9e3ae634419af4cce0ad98fdf69327
commit: 092c89667d9e3ae634419af4cce0ad98fdf69327
branch: main
author: Vyron Vasileiadis <[email protected]>
committer: ZeroIntensity <[email protected]>
date: 2026-09-10T12:27:38-04:00
summary:
gh-157208: Fix the `ctypes.util.struct` documentation (GH-157209)
files:
M Doc/library/ctypes.rst
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index d76c449626fab4..169459881328ab 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -708,7 +708,7 @@ Specifying function pointers using type annotations
@wrap_dll_function(dll_to_wrap)
def function_ptr_name(arg_name: ctypes_type, ...) -> ctypes_type:
- """Optional docstring. There should be no function body."""
+ """Optional docstring. There should be no function body."""
The body of the decorated function is ignored, and any parameters that are
missing type annotations are skipped. The names of the parameters are
ignored
@@ -728,7 +728,7 @@ Specifying function pointers using type annotations
@wrap_dll_function(ctypes.pythonapi)
def PyObject_GetAttrString(op: ctypes.py_object, attr: ctypes.c_char_p)
-> ctypes.py_object:
- pass
+ pass
PyObject_GetAttrString(42, b"real")
@@ -3207,7 +3207,7 @@ fields, or any other data types containing pointer type
fields.
that should be merged into a containing structure or union.
-.. decorator:: struct(*, align=None, layout, endian='native', pack=None)
+.. decorator:: struct(*, align=None, layout=None, endian='native', pack=None)
:module: ctypes.util
A :term:`decorator` that allows generating structure types using an
@@ -3244,14 +3244,18 @@ fields, or any other data types containing pointer type
fields.
.. code-block:: python
+ from typing import Annotated
+ from ctypes import c_ssize_t, c_void_p
+ from ctypes.util import struct, CFieldInfo
+
@struct
class PyObject:
- ob_refcnt: c_ssize_t
- ob_type: c_void_p
+ ob_refcnt: c_ssize_t
+ ob_type: c_void_p
@struct
class PyHovercraftObject:
- ob_base: Annotated[PyObject, CFieldInfo(anonymous=True)]
+ ob_base: Annotated[PyObject, CFieldInfo(anonymous=True)]
.. versionadded:: next
_______________________________________________
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]