Skip to content

Add Python 3.14 Linux Bluetooth socket constants#15893

Merged
srittau merged 1 commit into
python:mainfrom
popsiclelmlm:codex/socket-bluetooth-314
Jun 11, 2026
Merged

Add Python 3.14 Linux Bluetooth socket constants#15893
srittau merged 1 commit into
python:mainfrom
popsiclelmlm:codex/socket-bluetooth-314

Conversation

@popsiclelmlm

Copy link
Copy Markdown
Contributor

Summary

  • Add the Python 3.14 Linux Bluetooth socket constants that were still missing from the stdlib socket stubs.
  • Allow bare integer Bluetooth HCI device IDs in _socket._Address for Python 3.14+.
  • Extend the Linux stubtest allowlist for Bluetooth constants that may be absent from CI/runtime builds without Bluetooth support.

Reproduction

  • Bluetooth socket additions in Python 3.14 #15213 documents the Python 3.14 Linux runtime additions from a Debian Python 3.14.2 build, including BDADDR_*, BT_*, HCI_CHANNEL_*, L2CAP_*, and Bluetooth SOL_* constants.
  • The same issue notes that BTPROTO_HCI accepts a bare integer device_id in Python 3.14.

Root cause

  • The stubs already restored the base Bluetooth constants from restore bluetooth socket constants on Linux #15209, but the newer Python 3.14 Linux constants were not yet declared in _socket.pyi or re-exported from socket.pyi.
  • Some Linux builds, including GitHub Actions runners, do not expose Bluetooth constants at runtime, so the allowlist needs to keep these entries optional.

Changes

  • Add the missing Python 3.14 Linux Bluetooth constants to _socket.pyi.
  • Re-export those constants from socket.pyi under the existing Python 3.14 Linux block.
  • Widen _Address to include int only for Python 3.14+.
  • Add optional Linux stubtest allowlist entries for the new Bluetooth constants.

Tests

  • PATH=/tmp/typeshed-authlib-introspect-venv/bin:$PATH pre-commit run --files stdlib/_socket.pyi stdlib/socket.pyi stdlib/@tests/stubtest_allowlists/linux.txt
  • PATH=/tmp/typeshed-authlib-introspect-venv/bin:$PATH /tmp/typeshed-authlib-introspect-venv/bin/python tests/pyright_test.py stdlib/_socket.pyi stdlib/socket.pyi --pythonversion 3.14
  • PATH=/tmp/typeshed-authlib-introspect-venv/bin:$PATH /tmp/typeshed-authlib-introspect-venv/bin/python tests/mypy_test.py stdlib/_socket.pyi stdlib/socket.pyi --python-version 3.14 --platform linux darwin win32
  • PATH=/tmp/typeshed-authlib-introspect-venv/bin:$PATH /tmp/typeshed-authlib-introspect-venv/bin/python tests/check_typeshed_structure.py
  • PATH=/tmp/typeshed-authlib-introspect-venv/bin:$PATH /tmp/typeshed-authlib-introspect-venv/bin/python -m mypy.stubtest _socket socket --show-traceback --strict-type-check-only --custom-typeshed-dir . --ignore-unused-allowlist --allowlist stdlib/@tests/stubtest_allowlists/common.txt --allowlist stdlib/@tests/stubtest_allowlists/darwin.txt --allowlist stdlib/@tests/stubtest_allowlists/py314.txt --allowlist stdlib/@tests/stubtest_allowlists/darwin-py314.txt
  • git diff --check

Screenshots/Logs

  • N/A

Closes #15213

@github-actions

Copy link
Copy Markdown
Contributor

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

@srittau srittau 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!

@srittau srittau merged commit 8c73bec into python:main Jun 11, 2026
90 of 91 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.

Bluetooth socket additions in Python 3.14

2 participants