You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ctypes.util.struct example does not run and layout looks required #157208
The second @struct example in Doc/library/ctypes.rst cannot be run: it uses Annotated, CFieldInfo, c_ssize_t and c_void_p, and the page imports none of them. Carrying over the imports from the first example directly above it is not enough either.
$ ./python -c '
from ctypes.util import struct
from ctypes import c_int
@struct
class PyObject:
ob_refcnt: c_ssize_t
ob_type: c_void_p
'
Traceback (most recent call last):
...
File "<string>", line 7, in __annotate__
ob_refcnt: c_ssize_t
^^^^^^^^^
NameError: name 'c_ssize_t' is not defined
The same entry's signature line is struct(*, align=None, layout, endian='native', pack=None), which renders layout as a required parameter. ctypes.util.struct gives it a default:
Activity
gh-157208: Fix the `ctypes.util.struct` documentation (GH-157209)
pythongh-157208: Fix the `ctypes.util.struct` documentation (pythonGH…
pythongh-157208: Fix the `ctypes.util.struct` documentation (pythonGH…