Skip to content
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
61b540f
socket : add python 3.14 bluetooth constants for windows and linux
Divyanshudevtalla Jan 27, 2026
f460d10
socket: add Python 3.14 bluetooth constant with version guards
Divyanshudevtalla Jan 27, 2026
541eb42
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 27, 2026
8875184
address review: move constants to semi-documented and add allowlist …
Divyanshudevtalla Jan 28, 2026
83ca700
address review : move constants to semi-documented and fix version gu…
Divyanshudevtalla Jan 28, 2026
d8ee6b5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 28, 2026
717f7cb
fix: resolve merge conflict and update allowlist
Divyanshudevtalla Jan 28, 2026
74c8f48
fix: resolve sync issue and finalize allowlist
Divyanshudevtalla Jan 28, 2026
3efa725
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 28, 2026
b9f25b7
fix : resolve all CI faillures by updating socket.pyi and cleaning ma…
Divyanshudevtalla Jan 28, 2026
78ddaf3
fix: sync with remote and finalize socket constants
Divyanshudevtalla Jan 28, 2026
096518f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 28, 2026
e5a8806
refactor: remove duplicates,sort alphabatecally, and update allowlist
Divyanshudevtalla Jan 28, 2026
ac8ecb8
Merge branch 'add-bluetooth-constants' of https://github.com/Divyansh…
Divyanshudevtalla Jan 28, 2026
f2eb6ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 28, 2026
16415a6
Fix : add missing runtime constants to linux-py314 allowlist
Divyanshudevtalla Jan 29, 2026
a987b39
Fix: add platform-specific allowlists and remove reduntant entries
Divyanshudevtalla Jan 29, 2026
d73e6e7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 29, 2026
a7e5293
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 29, 2026
b1a62e3
fix : remaining fails fix
Divyanshudevtalla Jan 29, 2026
457e7fe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 29, 2026
e0056ab
Fix : update plateform allowlist
Divyanshudevtalla Jan 29, 2026
db48b40
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 29, 2026
e8bff12
updating fixes
Divyanshudevtalla Jan 29, 2026
7827112
fix updating
Divyanshudevtalla Jan 29, 2026
4cf8971
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -550,3 +550,70 @@ xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signatu
# These would ideally be special-cased by type checkers; see https://github.com/python/mypy/issues/2220
xml.etree.ElementTree.Element.__iter__
xml.etree.cElementTree.Element.__iter__
_socket.BDADDR_BREDR
Copy link

Choose a reason for hiding this comment

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

I don't see anything existing in this file for _socket.*, so I don't think we should be adding anything here.

_socket.BDADDR_LE_PUBLIC
_socket.BDADDR_LE_RANDOM
_socket.BT_CHANNEL_POLICY
_socket.BT_CHANNEL_POLICY_BREDR_ONLY
_socket.BT_CHANNEL_POLICY_BREDR_PREFERRED
_socket.BT_CODEC
_socket.BT_DEFER_SETUP
_socket.BT_FLUSHABLE
_socket.BT_FLUSHABLE_OFF
_socket.BT_FLUSHABLE_ON
_socket.BT_ISO_QOS
_socket.BT_MODE
_socket.BT_MODE_BASIC
_socket.BT_MODE_ERTM
_socket.BT_MODE_STREAM
_socket.BT_PHY
_socket.BT_PHY_BR_1M_1SLOT
_socket.BT_PHY_EDR_2M_1SLOT
_socket.BT_PHY_EDR_2M_3SLOT
_socket.BT_PHY_EDR_2M_5SLOT
_socket.BT_PHY_EDR_3M_1SLOT
_socket.BT_PHY_EDR_3M_3SLOT
_socket.BT_PHY_EDR_3M_5SLOT
_socket.BT_PHY_LE_1M_RX
_socket.BT_PHY_LE_1M_TX
_socket.BT_PHY_LE_2M_RX
_socket.BT_PHY_LE_2M_TX
_socket.BT_PHY_LE_CODED_RX
_socket.BT_PHY_LE_CODED_TX
_socket.BT_PKT_STATUS
_socket.BT_POWER
_socket.BT_POWER_FORCE_ACTIVE_OFF
_socket.BT_POWER_FORCE_ACTIVE_ON
_socket.BT_RCVMTU
_socket.BT_SCM_PKT_STATUS
_socket.BT_SNDMTU
_socket.BT_VOICE
_socket.BT_VOICE_FOR_MSBC
_socket.SOL_SCO
_socket.SOL_RFCOMM
_socket.SOL_L2CAP
_socket.BT_SECURITY
_socket.BT_SECURITY_FIPS
_socket.BT_SECURITY_HIGH
_socket.BT_SECURITY_LOW
_socket.BT_SECURITY_MEDIUM
_socket.BT_SECURITY_SDP
_socket.BT_VOICE_CVSD_16BIT
_socket.BT_VOICE_TRANSPARENT
_socket.BT_VOICE_TRANSPARENT_16BIT
_socket.HCI_CHANNEL_CONTROL
_socket.HCI_CHANNEL_LOGGING
_socket.HCI_CHANNEL_MONITOR
_socket.HCI_CHANNEL_RAW
_socket.HCI_CHANNEL_USER
_socket.HCI_DEV_NONE
_socket.L2CAP_LM
_socket.L2CAP_LM_AUTH
_socket.L2CAP_LM_ENCRYPT
_socket.L2CAP_LM_MASTER
_socket.L2CAP_LM_RELIABLE
_socket.L2CAP_LM_SECURE
_socket.L2CAP_LM_TRUSTED
_socket.SOL_BLUETOOTH
_socket.SOL_L2CAP
_socket.SOL_SCO
67 changes: 66 additions & 1 deletion stdlib/@tests/stubtest_allowlists/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,72 @@ select.poll # Actually a function; we have a class so it can be used as a type
(_?socket\.BTPROTO_L2CAP)?
(_?socket\.BTPROTO_RFCOMM)?
(_?socket\.BTPROTO_SCO)?

_socket.BDADDR_BREDR
Copy link

Choose a reason for hiding this comment

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

Suggested change
_socket.BDADDR_BREDR
(_?socket.BDADDR_BREDR)?

This and all the others being added need to follow the existing pattern.

_socket.BDADDR_LE_PUBLIC
_socket.BDADDR_LE_RANDOM
_socket.BT_CHANNEL_POLICY
_socket.BT_CHANNEL_POLICY_BREDR_ONLY
_socket.BT_CHANNEL_POLICY_BREDR_PREFERRED
_socket.BT_CODEC
_socket.BT_DEFER_SETUP
_socket.BT_FLUSHABLE
_socket.BT_FLUSHABLE_OFF
_socket.BT_FLUSHABLE_ON
_socket.BT_ISO_QOS
_socket.BT_MODE
_socket.BT_MODE_BASIC
_socket.BT_MODE_ERTM
_socket.BT_MODE_EXT_FLOWCTL
_socket.BT_MODE_LE_FLOWCTL
_socket.BT_MODE_STREAMING
_socket.BT_PHY
_socket.BT_PHY_BR_1M_1SLOT
_socket.BT_PHY_BR_1M_3SLOT
_socket.BT_PHY_BR_1M_5SLOT
_socket.BT_PHY_EDR_2M_1SLOT
_socket.BT_PHY_EDR_2M_3SLOT
_socket.BT_PHY_EDR_2M_5SLOT
_socket.BT_PHY_EDR_3M_1SLOT
_socket.BT_PHY_EDR_3M_3SLOT
_socket.BT_PHY_EDR_3M_5SLOT
_socket.BT_PHY_LE_1M_RX
_socket.BT_PHY_LE_1M_TX
_socket.BT_PHY_LE_2M_RX
_socket.BT_PHY_LE_2M_TX
_socket.BT_PHY_LE_CODED_RX
_socket.BT_PHY_LE_CODED_TX
_socket.BT_PKT_STATUS
_socket.BT_POWER
_socket.BT_POWER_FORCE_ACTIVE_OFF
_socket.BT_POWER_FORCE_ACTIVE_ON
_socket.BT_RCVMTU
_socket.BT_SECURITY
_socket.BT_SECURITY_FIPS
_socket.BT_SECURITY_HIGH
_socket.BT_SECURITY_LOW
_socket.BT_SECURITY_MEDIUM
_socket.BT_SECURITY_SDP
_socket.BT_SNDMTU
_socket.BT_VOICE
_socket.BT_VOICE_CVSD_16BIT
_socket.BT_VOICE_TRANSPARENT
_socket.BT_VOICE_TRANSPARENT_16BIT
_socket.HCI_CHANNEL_CONTROL
_socket.HCI_CHANNEL_LOGGING
_socket.HCI_CHANNEL_MONITOR
_socket.HCI_CHANNEL_RAW
_socket.HCI_CHANNEL_USER
_socket.HCI_DEV_NONE
_socket.L2CAP_LM
_socket.L2CAP_LM_AUTH
_socket.L2CAP_LM_ENCRYPT
_socket.L2CAP_LM_MASTER
_socket.L2CAP_LM_RELIABLE
_socket.L2CAP_LM_SECURE
_socket.L2CAP_LM_TRUSTED
_socket.SOL_BLUETOOTH
_socket.SOL_L2CAP
_socket.SOL_SCO
Copy link

Choose a reason for hiding this comment

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

Suggested change
_socket.SOL_L2CAP
_socket.SOL_SCO

These are duplicate. Please check the list for other duplicates. Sorting the list in alphabetical order should make it easy to catch these.

# These seem like they should be available on Linux, but they're not
# on GitHub Actions runners for some reason.
_?socket.IPX_TYPE
Expand Down
127 changes: 118 additions & 9 deletions stdlib/_socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ _CMSGArg: TypeAlias = tuple[int, int, ReadableBuffer]
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
# AF_NETLINK, AF_TIPC) or strings/buffers (AF_UNIX).
# See getsockaddrarg() in socketmodule.c.
_Address: TypeAlias = tuple[Any, ...] | str | ReadableBuffer
_Address: TypeAlias = (
tuple[Any, ...] | str | ReadableBuffer | int
) # int is included because of device_id not packed in a tuple is now accepted for BTPROTO_HCI
Copy link

Choose a reason for hiding this comment

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

The comment should be part of the existing comment above, not a new comment.

_RetAddress: TypeAlias = Any

# ===== Constants =====
Expand Down Expand Up @@ -76,6 +78,11 @@ if sys.platform != "linux":
SO_USELOOPBACK: Final[int]
if sys.platform == "win32":
SO_EXCLUSIVEADDRUSE: Final[int]
SO_BTH_ENCRYPT: Final[int]
SO_BTH_MTU: Final[int]
SO_BTH_MTU_MAX: Final[int]
SO_BTH_MTU_MIN: Final[int]
SOL_RFCOMM: Final[int]
if sys.platform != "win32":
SO_REUSEPORT: Final[int]
if sys.platform != "darwin" or sys.version_info >= (3, 13):
Expand Down Expand Up @@ -240,11 +247,6 @@ if sys.version_info >= (3, 14):
SO_ORIGINAL_DST: Final[int]

if sys.platform == "win32":
SOL_RFCOMM: Final[int]
SO_BTH_ENCRYPT: Final[int]
SO_BTH_MTU: Final[int]
SO_BTH_MTU_MAX: Final[int]
SO_BTH_MTU_MIN: Final[int]
TCP_QUICKACK: Final[int]

if sys.platform == "linux":
Expand Down Expand Up @@ -579,7 +581,47 @@ if sys.platform == "linux":
SO_VM_SOCKETS_BUFFER_SIZE: Final = 0
SO_VM_SOCKETS_BUFFER_MIN_SIZE: Final = 1
VM_SOCKETS_INVALID_VERSION: Final = 0xFFFFFFFF # undocumented

# Bluetooth constants new in 3.14
if sys.version_info >= (3, 14):
BDADDR_BREDR: int
BDADDR_LE_PUBLIC: int
BDADDR_LE_RANDOM: int
BT_CHANNEL_POLICY: int
BT_CHANNEL_POLICY_BREDR_ONLY: int
BT_CHANNEL_POLICY_BREDR_PREFERRED: int
BT_CODEC: int
BT_DEFER_SETUP: int
BT_FLUSHABLE: int
BT_FLUSHABLE_OFF: int
BT_FLUSHABLE_ON: int
BT_ISO_QOS: int
BT_MODE: int
BT_MODE_BASIC: int
BT_MODE_ERTM: int
BT_MODE_STREAM: int
BT_PHY: int
BT_PHY_BR_1M_1SLOT: int
BT_PHY_EDR_2M_1SLOT: int
BT_PHY_EDR_2M_3SLOT: int
BT_PHY_EDR_2M_5SLOT: int
BT_PHY_EDR_3M_1SLOT: int
BT_PHY_EDR_3M_3SLOT: int
BT_PHY_EDR_3M_5SLOT: int
BT_PHY_LE_1M_RX: int
BT_PHY_LE_1M_TX: int
BT_PHY_LE_2M_RX: int
BT_PHY_LE_2M_TX: int
BT_PHY_LE_CODED_RX: int
BT_PHY_LE_CODED_TX: int
BT_PKT_STATUS: int
BT_POWER: int
BT_POWER_FORCE_ACTIVE_OFF: int
BT_POWER_FORCE_ACTIVE_ON: int
BT_RCVMTU: int
BT_SCM_PKT_STATUS: int
BT_SNDMTU: int
BT_VOICE: int
BT_VOICE_FOR_MSBC: int
# Documented as only available on BSD, macOS, but empirically sometimes
# available on Windows
if sys.platform != "linux":
Expand Down Expand Up @@ -630,9 +672,76 @@ if sys.version_info >= (3, 12):
ETHERTYPE_IP: Final[int]
ETHERTYPE_IPV6: Final[int]
ETHERTYPE_VLAN: Final[int]
# --------------------
# Semi-documented constants
BDADDR_BREDR: Final[int]
BDADDR_LE_PUBLIC: Final[int]
BDADDR_LE_RANDOM: Final[int]
BT_CHANNEL_POLICY: Final[int]
BT_CHANNEL_POLICY_BREDR_ONLY: Final[int]
BT_CHANNEL_POLICY_BREDR_PREFERRED: Final[int]
BT_CODEC: Final[int]
BT_DEFER_SETUP: Final[int]
BT_FLUSHABLE: Final[int]
BT_FLUSHABLE_OFF: Final[int]
BT_FLUSHABLE_ON: Final[int]
BT_ISO_QOS: Final[int]
BT_MODE: Final[int]
BT_MODE_BASIC: Final[int]
BT_MODE_ERTM: Final[int]
BT_MODE_EXT_FLOWCTL: Final[int]
BT_MODE_LE_FLOWCTL: Final[int]
BT_MODE_STREAMING: Final[int]
BT_PHY: Final[int]
BT_PHY_BR_1M_1SLOT: Final[int]
BT_PHY_BR_1M_3SLOT: Final[int]
BT_PHY_BR_1M_5SLOT: Final[int]
BT_PHY_EDR_2M_1SLOT: Final[int]
BT_PHY_EDR_2M_3SLOT: Final[int]
BT_PHY_EDR_2M_5SLOT: Final[int]
BT_PHY_EDR_3M_1SLOT: Final[int]
BT_PHY_EDR_3M_3SLOT: Final[int]
BT_PHY_EDR_3M_5SLOT: Final[int]
BT_PHY_LE_1M_RX: Final[int]
BT_PHY_LE_1M_TX: Final[int]
BT_PHY_LE_2M_RX: Final[int]
BT_PHY_LE_2M_TX: Final[int]
BT_PHY_LE_CODED_RX: Final[int]
BT_PHY_LE_CODED_TX: Final[int]
BT_PKT_STATUS: Final[int]
BT_POWER: Final[int]
BT_POWER_FORCE_ACTIVE_OFF: Final[int]
BT_POWER_FORCE_ACTIVE_ON: Final[int]
BT_RCVMTU: Final[int]
BT_SECURITY: Final[int]
BT_SECURITY_FIPS: Final[int]
BT_SECURITY_HIGH: Final[int]
BT_SECURITY_LOW: Final[int]
BT_SECURITY_MEDIUM: Final[int]
BT_SECURITY_SDP: Final[int]
BT_SNDMTU: Final[int]
BT_VOICE: Final[int]
BT_VOICE_CVSD_16BIT: Final[int]
BT_VOICE_TRANSPARENT: Final[int]
BT_VOICE_TRANSPARENT_16BIT: Final[int]
HCI_CHANNEL_CONTROL: Final[int]
HCI_CHANNEL_LOGGING: Final[int]
HCI_CHANNEL_MONITOR: Final[int]
HCI_CHANNEL_RAW: Final[int]
HCI_CHANNEL_USER: Final[int]
HCI_DEV_NONE: Final[int]
L2CAP_LM: Final[int]
L2CAP_LM_AUTH: Final[int]
L2CAP_LM_ENCRYPT: Final[int]
L2CAP_LM_MASTER: Final[int]
L2CAP_LM_RELIABLE: Final[int]
L2CAP_LM_SECURE: Final[int]
L2CAP_LM_TRUSTED: Final[int]
SOL_BLUETOOTH: Final[int]
SOL_L2CAP: Final[int]
SOL_RFCOMM: Final[int]
SOL_SCO: Final[int]

# --------------------
# Semi-documented constants
Copy link

Choose a reason for hiding this comment

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

Please don't move this comment. Instead the new Bluetooth constants should be added somewhere below here.

# These are alluded to under the "Socket families" section in the docs
# https://docs.python.org/3/library/socket.html#socket-families
# --------------------
Expand Down
Loading