Skip to content

Set explicit ctypes _layout_ in coff.py for Python 3.14#693

Merged
rhelmot merged 1 commit into
angr:masterfrom
DanielBotnik:fix-ctypes-layout-py314
Jun 7, 2026
Merged

Set explicit ctypes _layout_ in coff.py for Python 3.14#693
rhelmot merged 1 commit into
angr:masterfrom
DanielBotnik:fix-ctypes-layout-py314

Conversation

@DanielBotnik

Copy link
Copy Markdown
Contributor

Summary

Python 3.14 deprecates the implicit memory layout for ctypes Structures that set _pack_, requiring an explicit _layout_. The implicit default is slated to become an error in Python 3.19.

This produced:

DeprecationWarning: Due to '_pack_', the 'CoffFileHeader' Structure will use memory layout
compatible with MSVC (Windows). If this is intended, set _layout_ to 'ms'. The implicit
default is deprecated and slated to become an error in Python 3.19.

COFF is a Windows/MSVC format, and the implicit default has always been the MSVC layout, so this sets _layout_ = "ms" on the four affected structures (CoffFileHeader, CoffSectionTableEntry, CoffSymbolTableEntry, CoffRelocationTableEntry) to preserve behavior and silence the warning.

Compatibility

_layout_ is ignored as an unknown class attribute on Python 3.12/3.13, so the change is a no-op on older supported versions (requires-python = ">=3.12").

Verification

Importing the module with DeprecationWarning promoted to an error no longer warns, and packed struct sizes are unchanged (20-byte header, 10-byte relocation entry).

🤖 Generated with Claude Code

Python 3.14 deprecates the implicit memory layout for ctypes
Structures that set _pack_, requiring an explicit _layout_ (slated
to become an error in 3.19). COFF is a Windows/MSVC format, and the
implicit default has always been the MSVC layout, so set
_layout_ = "ms" to preserve behavior and silence the warning.

The attribute is ignored on Python 3.12/3.13, so older supported
versions are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rhelmot rhelmot merged commit 55345de into angr:master Jun 7, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants