Skip to content

gh-104533: Fix @ctypes.util.struct with endian#154038

Open
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:struct_endian
Open

gh-104533: Fix @ctypes.util.struct with endian#154038
vstinner wants to merge 2 commits into
python:mainfrom
vstinner:struct_endian

Conversation

@vstinner

@vstinner vstinner commented Jul 19, 2026

Copy link
Copy Markdown
Member

Change _fields_ type to a list of tuples, instead of a list of lists.

Modify test.test_ctypes.test_aligned_structures to test also @ctypes.util.struct decorator.

Change _fields_ type to a list of tuples, instead of a list of lists.

Modify test.test_ctypes.test_aligned_structures to test also
@ctypes.util.struct decorator.
@vstinner

Copy link
Copy Markdown
Member Author

Union classes created with get_union_base() are not tested with @ctypes.util.struct since this decorator is for structures, not for unions.

@vstinner

Copy link
Copy Markdown
Member Author

cc @ZeroIntensity

Union classes created with get_union_base() are not tested with @ctypes.util.struct since this decorator is for structures, not for unions.

Later, it would be interesting to add @ctypes.util.union decorator for union classes ;-)

@ZeroIntensity

Copy link
Copy Markdown
Member

Later, it would be interesting to add @ctypes.util.union decorator for union classes ;-)

Agreed. I had left it out of the original PR because it seemed like there was less demand for it, but I'd be happy to review a PR or contribute it myself.

Comment thread Lib/ctypes/util.py

fields.append(field)
# _fields_ is a list of tuples
fields.append(tuple(field))

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.

If we get take_tuple in 3.16, we should switch to that here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants