Skip to content

gh-104533: Use @ctypes.util.struct decorator#154031

Merged
vstinner merged 10 commits into
python:mainfrom
vstinner:ctypes_struct
Jul 19, 2026
Merged

gh-104533: Use @ctypes.util.struct decorator#154031
vstinner merged 10 commits into
python:mainfrom
vstinner:ctypes_struct

Conversation

@vstinner

@vstinner vstinner commented Jul 18, 2026

Copy link
Copy Markdown
Member

Use also @ctypes.util.wrap_dll_function() decorator.

Use also @ctypes.util.wrap_dll_function() decorator.
@vstinner

Copy link
Copy Markdown
Member Author

Oh, I had to revert changes because I found multiple bugs in @ctypes.util.struct.

@vstinner
vstinner marked this pull request as draft July 19, 2026 01:03
@vstinner

Copy link
Copy Markdown
Member Author

Oh, I had to revert changes because I found multiple bugs in @ctypes.util.struct:

@vstinner
vstinner marked this pull request as ready for review July 19, 2026 11:22
_pyrepl is tested by mypy which doesn't know yet about
@ctypes.util.struct.
@vstinner

Copy link
Copy Markdown
Member Author

I converted structures of Lib/_pyrepl/windows_console.py to @ctypes.util.struct. The problem is that this file is tested by mypy with Python 3.15 which doesn't know about @ctypes.util.struct. So I reverted _pyrepl changes.

@vstinner

Copy link
Copy Markdown
Member Author

There are many structures defined in:

  • Lib/test/leakers/test_ctypes.py
  • Lib/test/test_ctypes/
  • ctypes.util
  • ctypes.wintypes
  • _pyrepl.windows_console

For _pyrepl, I left it unchanged because of the mypy issue described above.

ctypes sub-modules cannot use @ctypes.util.struct because they are used by ctypes.util (inter-dependencies).

test_ctypes contains just too many structures, I'm not suret that it's worth it to convert all of them.

@vstinner
vstinner enabled auto-merge (squash) July 19, 2026 12:06
@vstinner
vstinner merged commit ee50ed3 into python:main Jul 19, 2026
48 checks passed
@vstinner
vstinner deleted the ctypes_struct branch July 19, 2026 12:08
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.

1 participant