Skip to content

Fix Python 3.14 DeprecationWarning caused by implicit ctypes layout when using _pack_ = 1.#112

Merged
vpelletier merged 1 commit into
vpelletier:masterfrom
DedUndead:pack-deprecation
May 16, 2026
Merged

Fix Python 3.14 DeprecationWarning caused by implicit ctypes layout when using _pack_ = 1.#112
vpelletier merged 1 commit into
vpelletier:masterfrom
DedUndead:pack-deprecation

Conversation

@DedUndead
Copy link
Copy Markdown
Contributor

@DedUndead DedUndead commented May 15, 2026

Fix addresses issue #111.
This change adds _layout_ = "ms" to libusb_control_setup and newStruct structures to explicitly preserve the existing MSVC-compatible structure layout and avoid the warning becoming an error in future Python versions.
Without this fix, importing usb1 on Python 3.14 with warnings treated as errors fails with DeprecationWarning.

Tested with:

  • Python 3.14.3
  • Ubuntu 24.04.3 LTS

python3.14 -W error::DeprecationWarning -c "import usb1"

@vpelletier
Copy link
Copy Markdown
Owner

Thank you for a nice bug report.

_pack_ is present in one more place, in usb1._libusb1.newStruct. Could you apply a similar change there too, in the same commit ?

Implicit behavior of _pack_ is deprecated in Python 3.14.
Eliminate warning by explicitly setting _layout_ attribute to "ms".
@DedUndead
Copy link
Copy Markdown
Contributor Author

@vpelletier Thank you for prompt response. Good catch, I amended per your request and updated pull request description.

@vpelletier vpelletier merged commit 0c64d8f into vpelletier:master May 16, 2026
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