Skip to content

Update _socket and socket for 3.14 #14055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 0 additions & 14 deletions stdlib/@tests/stubtest_allowlists/linux-py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

_curses.assume_default_colors
_posixsubprocess.fork_exec
_socket.CAN_RAW_ERR_FILTER
_socket.IPV6_RECVERR
_socket.IP_FREEBIND
_socket.IP_RECVERR
_socket.IP_RECVORIGDSTADDR
_socket.SO_ORIGINAL_DST
_socket.VMADDR_CID_LOCAL
asyncio.tools
asyncio.unix_events.__all__
asyncio.unix_events.DefaultEventLoopPolicy
Expand All @@ -27,10 +20,3 @@ posix.SCHED_DEADLINE
posix.SCHED_NORMAL
posix.readinto
select.EPOLLWAKEUP
socket.CAN_RAW_ERR_FILTER
socket.IPV6_RECVERR
socket.IP_FREEBIND
socket.IP_RECVERR
socket.IP_RECVORIGDSTADDR
socket.SO_ORIGINAL_DST
socket.VMADDR_CID_LOCAL
5 changes: 0 additions & 5 deletions stdlib/@tests/stubtest_allowlists/py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ _heapq.heappush_max
_heapq.heappushpop_max
_heapq.heapreplace_max
_imp.pyc_magic_number_token
_socket.IP_RECVTTL
_socket.if_indextoname
_thread.RLock.locked
_thread.set_name
asyncio.__all__
Expand Down Expand Up @@ -97,9 +95,6 @@ pkgutil.find_loader
pkgutil.get_loader
pyexpat.errors.XML_ERROR_NOT_STARTED
shutil.__all__
socket.__all__
socket.IP_RECVTTL
socket.if_indextoname
sre_compile.CH_NEGATE
sre_constants.CH_NEGATE
sre_parse.CH_NEGATE
Expand Down
18 changes: 0 additions & 18 deletions stdlib/@tests/stubtest_allowlists/win32-py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
# TODO: New errors in Python 3.14 that need to be fixed or moved below
# ====================================================================

_socket.IPV6_RECVERR
_socket.IP_RECVERR
_socket.SOL_RFCOMM
_socket.SO_ORIGINAL_DST
_socket.SO_BTH_ENCRYPT
_socket.SO_BTH_MTU
_socket.SO_BTH_MTU_MAX
_socket.SO_BTH_MTU_MIN
_socket.TCP_QUICKACK
_winapi.COPY_FILE_DIRECTORY
asyncio.WindowsProactorEventLoopPolicy.get_child_watcher
asyncio.WindowsProactorEventLoopPolicy.set_child_watcher
Expand All @@ -31,15 +22,6 @@ encodings.win32_code_page_search_function
nt.readinto
pathlib.Path.group
pathlib.Path.owner
socket.IPV6_RECVERR
socket.IP_RECVERR
socket.SOL_RFCOMM
socket.SO_ORIGINAL_DST
socket.SO_BTH_ENCRYPT
socket.SO_BTH_MTU
socket.SO_BTH_MTU_MAX
socket.SO_BTH_MTU_MIN
socket.TCP_QUICKACK
winsound.MB_ICONERROR
winsound.MB_ICONINFORMATION
winsound.MB_ICONSTOP
Expand Down
29 changes: 28 additions & 1 deletion stdlib/_socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,28 @@ if sys.platform != "win32":
IP_RECVOPTS: int
IP_RECVRETOPTS: int
IP_RETOPTS: int
if sys.version_info >= (3, 14):
IP_RECVTTL: int

if sys.platform == "win32" or sys.platform == "linux":
IPV6_RECVERR: int
IP_RECVERR: int
SO_ORIGINAL_DST: int

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

if sys.platform == "linux":
CAN_RAW_ERR_FILTER: int
IP_FREEBIND: int
IP_RECVORIGDSTADDR: int
VMADDR_CID_LOCAL: int

if sys.platform != "win32" and sys.platform != "darwin":
IP_TRANSPARENT: int
if sys.platform != "win32" and sys.platform != "darwin" and sys.version_info >= (3, 11):
Expand Down Expand Up @@ -829,6 +851,11 @@ if sys.platform != "win32":

def if_nameindex() -> list[tuple[int, str]]: ...
def if_nametoindex(oname: str, /) -> int: ...
def if_indextoname(index: int, /) -> str: ...

if sys.version_info >= (3, 14):
def if_indextoname(if_index: int, /) -> str: ...

else:
def if_indextoname(index: int, /) -> str: ...

CAPI: CapsuleType
33 changes: 33 additions & 0 deletions stdlib/socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,39 @@ if sys.platform != "linux":

__all__ += ["IPPROTO_GGP", "IPPROTO_IPV4", "IPPROTO_MAX", "IPPROTO_ND", "IP_RECVDSTADDR", "SO_USELOOPBACK"]

if sys.version_info >= (3, 14):
from _socket import IP_RECVTTL as IP_RECVTTL

__all__ += ["IP_RECVTTL"]

if sys.platform == "win32" or sys.platform == "linux":
from _socket import IP_RECVERR as IP_RECVERR, IPV6_RECVERR as IPV6_RECVERR, SO_ORIGINAL_DST as SO_ORIGINAL_DST

__all__ += ["IP_RECVERR", "IPV6_RECVERR", "SO_ORIGINAL_DST"]

if sys.platform == "win32":
from _socket import (
SO_BTH_ENCRYPT as SO_BTH_ENCRYPT,
SO_BTH_MTU as SO_BTH_MTU,
SO_BTH_MTU_MAX as SO_BTH_MTU_MAX,
SO_BTH_MTU_MIN as SO_BTH_MTU_MIN,
SOL_RFCOMM as SOL_RFCOMM,
TCP_QUICKACK as TCP_QUICKACK,
)

__all__ += ["SOL_RFCOMM", "SO_BTH_ENCRYPT", "SO_BTH_MTU", "SO_BTH_MTU_MAX", "SO_BTH_MTU_MIN", "TCP_QUICKACK"]

if sys.platform == "linux":
from _socket import (
CAN_RAW_ERR_FILTER as CAN_RAW_ERR_FILTER,
IP_FREEBIND as IP_FREEBIND,
IP_RECVORIGDSTADDR as IP_RECVORIGDSTADDR,
SO_ORIGINAL_DST as SO_ORIGINAL_DST,
VMADDR_CID_LOCAL as VMADDR_CID_LOCAL,
)

__all__ += ["CAN_RAW_ERR_FILTER", "IP_FREEBIND", "IP_RECVORIGDSTADDR", "VMADDR_CID_LOCAL"]

# Re-exported from errno
EBADF: int
EAGAIN: int
Expand Down