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

gh-104533: Fix `@ctypes.util.struct` with endian by vstinner · Pull Request #154038 · python/cpython · GitHub

Repository navigation

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

Merged
vstinner merged 2 commits into
python:mainfrom
vstinner:struct_endian
Jul 19, 2026
Merged

vstinner merged 2 commits into
python:mainfrom
vstinner:struct_endian

Conversation

vstinner commented Jul 19, 2026 •
edited
Loading

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.

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.

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 ;-)

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.

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

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

vstinner merged commit e260051 into python:main Jul 19, 2026
52 checks passed
vstinner deleted the struct_endian branch July 19, 2026 10:07

Copy link
Copy Markdown
Member Author

Merged, thanks for the review.

hugovk commented Jul 19, 2026

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member

It was caused by a combination of PRs. Victor already has a fix up.

Copy link
Copy Markdown
Member Author

test_ctypes is failing

Sorry for the noise. It has already been fixed by #154091.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL