Skip to content

Expose Bluetooth HCI socket constants on Linux - #16423

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
anistark:fix-socket-hci-linux
Sep 22, 2026
Merged

JelleZijlstra merged 1 commit into
python:mainfrom
anistark:fix-socket-hci-linux

Conversation

@anistark

Copy link
Copy Markdown
Contributor

HCI_FILTER, HCI_TIME_STAMP and HCI_DATA_DIR are declared only for platforms other than Windows, macOS and Linux, so type checkers report them as missing on Linux even though CPython exposes them there when built with Bluetooth support. The socket docs list them as unavailable only on NetBSD, DragonFlyBSD and, for the latter two, FreeBSD, and socketmodule.c adds them whenever the macros are defined.

Declare them on Linux in _socket and socket, following the same pattern already used for BTPROTO_HCI: the __all__ entries stay excluded on Linux and the names are added as optional entries to the Linux stubtest allowlist, because the GitHub Actions runners build Python without Bluetooth headers.

Related: #15213

`HCI_FILTER`, `HCI_TIME_STAMP` and `HCI_DATA_DIR` were only declared
for platforms other than Windows, macOS and Linux, so type checkers
reported them as missing on Linux even though CPython defines them
there whenever it is built with Bluetooth support. The CPython docs
list them as unavailable only on NetBSD, DragonFlyBSD and (for the
latter two) FreeBSD.

Declare them on Linux in `_socket` and `socket`, following the same
pattern already used for `BTPROTO_HCI`: the `__all__` entries stay
excluded on Linux and the names are added as optional entries to the
Linux stubtest allowlist, because the GitHub Actions runners build
Python without Bluetooth headers.
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra
JelleZijlstra merged commit 88806a5 into python:main Sep 22, 2026
88 checks passed
@anistark
anistark deleted the fix-socket-hci-linux branch September 22, 2026 15:09
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