Skip to content

Set _layout_ = "ms" on packed ctypes structs in SYSTEC and Vector interfaces (Python 3.14) - #2162

Merged
zariiii9003 merged 2 commits into
hardbyte:mainfrom
anish-01:fix-py314-ctypes-layout
Nov 29, 2026
Merged

zariiii9003 merged 2 commits into
hardbyte:mainfrom
anish-01:fix-py314-ctypes-layout

Conversation

@anish-01

Copy link
Copy Markdown
Contributor

On Python 3.14, the packed ctypes structures in the SYSTEC (can/interfaces/systec/structures.py, 6 structs) and Vector (can/interfaces/vector/xlclass.py, 1 struct) interfaces raise a DeprecationWarning when the module is imported on Linux/macOS, because they set _pack_ = 1 without _layout_:

DeprecationWarning: Due to '_pack_', the '...' 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.

nican.py already sets _layout_ = "ms", so this just does the same for the other two interfaces.

Changes

  • Added _layout_ = "ms" next to each _pack_ = 1 in systec/structures.py and vector/xlclass.py
  • Added a changelog fragment (doc/changelog.d/+py314-ctypes-layout.fixed.rst)

No behavior change: "ms" is already the layout Python uses when _pack_ is set (and the native one on Windows, where these drivers run), and none of these structs use bitfields, so sizes and offsets stay the same.

Tested

  • Same pattern warns on 3.14 without _layout_ and is clean with it, same sizeof
  • Older Pythons just ignore the extra attribute
  • ruff check and black --check pass on the changed files
  • Didn't test with real SYSTEC/Vector hardware since only the struct definitions changed

@zariiii9003

Copy link
Copy Markdown
Collaborator

Looks good, rename the news fragment please.

@zariiii9003 zariiii9003 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@zariiii9003
zariiii9003 merged commit 8321e72 into hardbyte:main Nov 29, 2026
26 of 27 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