mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
host_env: publish remaining Windows socket constants (#8792)
* host_env: publish remaining Windows socket constants Windows SOMAXCONN follows winsock2.h (0x7fffffff), not the Winsock 1.1 value windows-sys still exports. The socket module takes the signed INADDR group constants and the other Winsock names host_env already defines. Assisted-by: Grok * test_socket: expect Bluetooth constants to pass on Windows The Windows names this test reads are published now, so the blanket expectedFailure is an unexpected success there. Other platforms still miss BTPROTO_HCI and the rest of the non-Windows set. Assisted-by: Grok
This commit is contained in:
1 parent
56df93a919
commit
05f1386fca
3 files changed
+28
-17
No files matched your search
Vendored
+3
-1
@@ -2698,7 +2698,9 @@ class BasicVSOCKTest(unittest.TestCase):
|
||||
'Bluetooth sockets required for this test.')
|
||||
class BasicBluetoothTest(unittest.TestCase):
|
||||
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module 'socket' has no attribute 'BTPROTO_RFCOMM'
|
||||
# Windows publishes the names below. Other platforms still miss
|
||||
# BTPROTO_HCI and the rest of the non-Windows set.
|
||||
@(unittest.expectedFailure if sys.platform != "win32" else (lambda func: func))
|
||||
def testBluetoothConstants(self):
|
||||
socket.BDADDR_ANY
|
||||
socket.BDADDR_LOCAL
|
||||
|
||||
@@ -1164,9 +1164,9 @@ pub use windows_sys::Win32::Networking::WinSock::{
|
||||
SO_DONTROUTE, SO_ERROR, SO_KEEPALIVE, SO_LINGER, SO_OOBINLINE, SO_RCVBUF, SO_RCVTIMEO,
|
||||
SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO, SO_TYPE, SO_USELOOPBACK, SOCK_DGRAM, SOCK_RAW, SOCK_RDM,
|
||||
SOCK_SEQPACKET, SOCK_STREAM, SOCKET_ERROR, SOCKET_ERROR as SOCKET_ERROR_CODE, SOL_IP,
|
||||
SOL_SOCKET, SOMAXCONN, TCP_MAXSEG, TCP_NODELAY, WSAEBADF, WSAECONNABORTED, WSAECONNRESET,
|
||||
WSAEINTR, WSAENOTSOCK, WSAEWOULDBLOCK, getprotobyname, getservbyname, getservbyport,
|
||||
getsockopt, setsockopt,
|
||||
SOL_SOCKET, TCP_MAXSEG, TCP_NODELAY, WSAEBADF, WSAECONNABORTED, WSAECONNRESET, WSAEINTR,
|
||||
WSAENOTSOCK, WSAEWOULDBLOCK, getprotobyname, getservbyname, getservbyport, getsockopt,
|
||||
setsockopt,
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -1204,6 +1204,10 @@ pub const AI_NUMERICHOST: i32 = windows_sys::Win32::Networking::WinSock::AI_NUME
|
||||
#[cfg(windows)]
|
||||
pub const FROM_PROTOCOL_INFO_VALUE: i32 = FROM_PROTOCOL_INFO;
|
||||
|
||||
/// `winsock2.h` `SOMAXCONN`. windows-sys still exports the Winsock 1.1 value 5.
|
||||
#[cfg(windows)]
|
||||
pub const SOMAXCONN: i32 = 0x7fff_ffff;
|
||||
|
||||
/// Signed C-long readings of option words, plus names the Winsock headers
|
||||
/// do not define that the module still carries.
|
||||
#[cfg(windows)]
|
||||
|
||||
+18
-13
@@ -225,15 +225,7 @@ mod _socket {
|
||||
|
||||
#[cfg(windows)]
|
||||
#[pyattr]
|
||||
const INADDR_UNSPEC_GROUP: u32 = 0xe0000000;
|
||||
|
||||
#[cfg(windows)]
|
||||
#[pyattr]
|
||||
const INADDR_ALLHOSTS_GROUP: u32 = 0xe0000001;
|
||||
|
||||
#[cfg(windows)]
|
||||
#[pyattr]
|
||||
const INADDR_MAX_LOCAL_GROUP: u32 = 0xe00000ff;
|
||||
use host_socket::{INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_UNSPEC_GROUP};
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
|
||||
#[pyattr]
|
||||
@@ -665,12 +657,25 @@ mod _socket {
|
||||
#[cfg(windows)]
|
||||
#[pyattr]
|
||||
use host_socket::{
|
||||
AF_BLUETOOTH, AF_HYPERV, AF_IRDA, AF_SNA, BTHPROTO_RFCOMM, HV_PROTOCOL_RAW,
|
||||
HVSOCKET_ADDRESS_FLAG_PASSTHRU, HVSOCKET_CONNECT_TIMEOUT, HVSOCKET_CONNECT_TIMEOUT_MAX,
|
||||
HVSOCKET_CONNECTED_SUSPEND, IPPROTO_CBT, IPPROTO_ICLFXBM, IPPROTO_IGP, IPPROTO_L2TP,
|
||||
IPPROTO_PGM, IPPROTO_RDP, IPPROTO_SCTP, IPPROTO_ST, SIO_TCP_SET_ACK_FREQUENCY,
|
||||
AF_BLUETOOTH, AF_HYPERV, AF_IRDA, AF_SNA, BTHPROTO_RFCOMM,
|
||||
BTHPROTO_RFCOMM as BTPROTO_RFCOMM, HV_PROTOCOL_RAW, HVSOCKET_ADDRESS_FLAG_PASSTHRU,
|
||||
HVSOCKET_CONNECT_TIMEOUT, HVSOCKET_CONNECT_TIMEOUT_MAX, HVSOCKET_CONNECTED_SUSPEND,
|
||||
IP_ADD_SOURCE_MEMBERSHIP, IP_BLOCK_SOURCE, IP_DROP_SOURCE_MEMBERSHIP, IP_PKTINFO,
|
||||
IP_RECVERR, IP_RECVTOS, IP_RECVTTL, IP_UNBLOCK_SOURCE, IPPROTO_CBT, IPPROTO_ICLFXBM,
|
||||
IPPROTO_IGP, IPPROTO_L2TP, IPPROTO_PGM, IPPROTO_RDP, IPPROTO_SCTP, IPPROTO_ST,
|
||||
IPV6_RECVERR, MSG_ERRQUEUE, RCVALL_MAX, SIO_TCP_SET_ACK_FREQUENCY, SO_ACCEPTCONN,
|
||||
SO_BTH_ENCRYPT, SO_BTH_MTU, SO_BTH_MTU_MAX, SO_BTH_MTU_MIN, SO_DEBUG, SO_DONTROUTE,
|
||||
SO_ORIGINAL_DST, SO_RCVLOWAT, SO_RCVTIMEO, SO_SNDLOWAT, SO_SNDTIMEO, SOL_RFCOMM,
|
||||
TCP_FASTOPEN, TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL,
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
#[pyattr]
|
||||
const BDADDR_ANY: &str = host_socket::BDADDR_ANY;
|
||||
#[cfg(windows)]
|
||||
#[pyattr]
|
||||
const BDADDR_LOCAL: &str = host_socket::BDADDR_LOCAL;
|
||||
|
||||
#[cfg(windows)]
|
||||
#[pyattr]
|
||||
const HV_GUID_ZERO: &str = host_socket::HV_GUID_ZERO;
|
||||
|
||||
Reference in new issue
Block a user