diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py310.txt b/stdlib/@tests/stubtest_allowlists/darwin-py310.txt index e2a10b3ed34f..fabe50b2d515 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py310.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py310.txt @@ -80,3 +80,10 @@ _msi msilib(.[a-z]+)? ossaudiodev spwd + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/darwin.txt b/stdlib/@tests/stubtest_allowlists/darwin.txt index bee977f6d21d..ff0c75b6634b 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin.txt @@ -56,3 +56,10 @@ tkinter.Tk.deletefilehandler # Methods that come from __getattr__() at runtime (_?locale.dgettext)? (_?locale.gettext)? (_?locale.textdomain)? + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/linux-py312.txt b/stdlib/@tests/stubtest_allowlists/linux-py312.txt index 9d9984713dcb..3e407fe6fa34 100644 --- a/stdlib/@tests/stubtest_allowlists/linux-py312.txt +++ b/stdlib/@tests/stubtest_allowlists/linux-py312.txt @@ -21,3 +21,8 @@ msilib(.[a-z]+)? # doesn't exist in all installations (nis)? + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Ubuntu test runners + +_socket.HCI_CHANNEL_RAW +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/linux-py314.txt b/stdlib/@tests/stubtest_allowlists/linux-py314.txt index 98f33e427a30..996788019618 100644 --- a/stdlib/@tests/stubtest_allowlists/linux-py314.txt +++ b/stdlib/@tests/stubtest_allowlists/linux-py314.txt @@ -5,3 +5,11 @@ # Starting with Python 3.14.1, these methods accept None for some of their # parameters, but would raise a TypeError with Python 3.14.0. mmap.mmap.madvise + +# Bluetooth constants new in 3.14 but missing at runtime on Ubuntu test runners +_socket.BT_MODE_STREAM +_socket.BT_PHY_LE_2M_RX +_socket.BT_SCM_PKT_STATUS +_socket.BT_VOICE_FOR_MSBC +_socket.HCI_CHANNEL_RAW +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/linux.txt b/stdlib/@tests/stubtest_allowlists/linux.txt index b652654f9780..798e268e3813 100644 --- a/stdlib/@tests/stubtest_allowlists/linux.txt +++ b/stdlib/@tests/stubtest_allowlists/linux.txt @@ -35,7 +35,70 @@ 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)? +(_?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_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_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)? # These seem like they should be available on Linux, but they're not # on GitHub Actions runners for some reason. _?socket.IPX_TYPE @@ -69,3 +132,8 @@ termios.TIOCTTYGSTRUCT tkinter.Tk.createfilehandler # Methods that come from __getattr__() at runtime tkinter.Tk.deletefilehandler # Methods that come from __getattr__() at runtime + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Ubuntu test runners + +_socket.HCI_CHANNEL_RAW +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/py310.txt b/stdlib/@tests/stubtest_allowlists/py310.txt index b11ea3c6c7db..f68edbbb1855 100644 --- a/stdlib/@tests/stubtest_allowlists/py310.txt +++ b/stdlib/@tests/stubtest_allowlists/py310.txt @@ -307,3 +307,10 @@ _pickle.Pickler.persistent_id _pickle.Unpickler.persistent_load pickle.Pickler.persistent_id pickle.Unpickler.persistent_load + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/py314.txt b/stdlib/@tests/stubtest_allowlists/py314.txt index 2ed18b5a2fea..e00e1f0678dc 100644 --- a/stdlib/@tests/stubtest_allowlists/py314.txt +++ b/stdlib/@tests/stubtest_allowlists/py314.txt @@ -228,3 +228,10 @@ builtins.property.__set_name__ # Doesn't actually exist collections\.UserList\.index # ignoring pos-or-keyword parameter dataclasses.KW_ONLY # white lies around defaults importlib.metadata._meta.SimplePath.joinpath # Runtime definition of protocol is incorrect + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/win32-py310.txt b/stdlib/@tests/stubtest_allowlists/win32-py310.txt index f067989f1418..9372bf775d46 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py310.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py310.txt @@ -80,3 +80,10 @@ crypt nis ossaudiodev spwd + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/win32-py312.txt b/stdlib/@tests/stubtest_allowlists/win32-py312.txt index f0e828de25f6..ed5adb61c74d 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py312.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py312.txt @@ -56,3 +56,10 @@ crypt nis ossaudiodev spwd + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/win32-py313.txt b/stdlib/@tests/stubtest_allowlists/win32-py313.txt index 070fce3e9c49..9211eac5fb9a 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py313.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py313.txt @@ -6,3 +6,10 @@ # (Hard to add types for unless we add stubs for the undocumented _overlapped module...) asyncio.IocpProactor.finish_socket_func asyncio.windows_events.IocpProactor.finish_socket_func + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/win32-py314.txt b/stdlib/@tests/stubtest_allowlists/win32-py314.txt index 070fce3e9c49..9211eac5fb9a 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py314.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py314.txt @@ -6,3 +6,10 @@ # (Hard to add types for unless we add stubs for the undocumented _overlapped module...) asyncio.IocpProactor.finish_socket_func asyncio.windows_events.IocpProactor.finish_socket_func + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/@tests/stubtest_allowlists/win32.txt b/stdlib/@tests/stubtest_allowlists/win32.txt index b56fe5a2042e..b55650a9a619 100644 --- a/stdlib/@tests/stubtest_allowlists/win32.txt +++ b/stdlib/@tests/stubtest_allowlists/win32.txt @@ -39,3 +39,10 @@ tty multiprocessing.popen_fork # exists on Windows but fails to import multiprocessing.popen_forkserver # exists on Windows but fails to import multiprocessing.popen_spawn_posix # exists on Windows but fails to import + +# Bluetooth constants added for Python 3.14+ but missing at runtime on Windows test runners +_socket.SO_BTH_ENCRYPT +_socket.SO_BTH_MTU +_socket.SO_BTH_MTU_MAX +_socket.SO_BTH_MTU_MIN +_socket.SOL_RFCOMM diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 372b35f22f17..00f4886059ff 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -11,7 +11,8 @@ _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 _RetAddress: TypeAlias = Any # ===== Constants ===== @@ -76,6 +77,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): @@ -240,11 +246,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": @@ -579,7 +580,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_BREDR_ONLY: int + BT_CHANNEL_POLICY_BREDR_PREFERRED: int + BT_CHANNEL_POLICY: int + BT_CODEC: int + BT_DEFER_SETUP: int + BT_FLUSHABLE_OFF: int + BT_FLUSHABLE_ON: int + BT_FLUSHABLE: int + BT_ISO_QOS: int + BT_MODE_BASIC: int + BT_MODE_ERTM: int + BT_MODE_STREAM: int + BT_MODE: 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_PHY: int + BT_PKT_STATUS: int + BT_POWER_FORCE_ACTIVE_OFF: int + BT_POWER_FORCE_ACTIVE_ON: int + BT_POWER: int + BT_RCVMTU: int + BT_SCM_PKT_STATUS: int + BT_SNDMTU: int + BT_VOICE_FOR_MSBC: int + BT_VOICE: int # Documented as only available on BSD, macOS, but empirically sometimes # available on Windows if sys.platform != "linux": @@ -630,9 +671,41 @@ if sys.version_info >= (3, 12): ETHERTYPE_IP: Final[int] ETHERTYPE_IPV6: Final[int] ETHERTYPE_VLAN: Final[int] + # -------------------- + # Semi-documented constants + + BT_MODE_EXT_FLOWCTL: Final[int] + BT_MODE_LE_FLOWCTL: Final[int] + BT_MODE_STREAMING: Final[int] + BT_PHY_BR_1M_3SLOT: Final[int] + BT_PHY_BR_1M_5SLOT: 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_SECURITY: Final[int] + BT_VOICE_CVSD_16BIT: Final[int] + BT_VOICE_TRANSPARENT_16BIT: Final[int] + BT_VOICE_TRANSPARENT: 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_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] + L2CAP_LM: Final[int] + SOL_BLUETOOTH: Final[int] + SOL_L2CAP: Final[int] + SOL_RFCOMM: Final[int] + SOL_SCO: Final[int] -# -------------------- -# Semi-documented constants # These are alluded to under the "Socket families" section in the docs # https://docs.python.org/3/library/socket.html#socket-families # --------------------