◐ Shell
clean mode source ↗

Fix socket.getaddrinfo and upgrade socket to 3.13.11 by youknowone · Pull Request #6564 · RustPython/RustPython

66-89: LGTM!

The Windows WinSock API additions are correctly imported, and FROM_PROTOCOL_INFO = -1 matches the documented WinSock constant value.


991-1054: LGTM!

The logic correctly masks out SOCK_NONBLOCK and SOCK_CLOEXEC flags from the stored socket type, ensuring consistent cross-platform behavior. The timeout initialization properly handles non-blocking sockets by setting timeout to 0.0.


1252-1314: LGTM!

The AF_ALG address handling correctly validates string lengths against the sockaddr_alg field sizes and properly initializes the zeroed structure before copying the type and name strings.


1402-1478: LGTM!

The Windows socket reconstruction from share() bytes is correctly implemented with proper size validation, WSASocketW usage, and error handling. The handle inheritance is properly disabled after creation.


1921-2009: LGTM!

The recvmsg implementation correctly handles buffer allocation, validates input parameters, and properly parses the received data and ancillary data. The return format matches Python's socket.recvmsg() specification.


2011-2045: LGTM!

The parse_ancillary_data function correctly handles control message iteration with proper truncation handling when MSG_CTRUNC occurs. The data length calculation respects both the cmsg_len field and the actual available buffer space.


2088-2093: LGTM!

Correctly using CMSG_LEN for the cmsg_len field (actual message length) while CMSG_SPACE is used for buffer allocation (includes padding). This matches the proper CMSG construction pattern.


2111-2141: LGTM with a note on close() error handling.

The __del__ implementation correctly emits ResourceWarning for unclosed sockets, matching Python's behavior. The close() error is appropriately ignored with let _ = since destructors shouldn't propagate errors.


2305-2408: LGTM!

The Windows ioctl implementation correctly handles the supported IOCTL commands with proper input validation and error handling. The TcpKeepalive struct is correctly marked #[repr(C)] for FFI compatibility.


2410-2433: LGTM!

The Windows share method correctly uses WSADuplicateSocketW to create a shareable socket descriptor and returns the protocol info as bytes, which can be used by another process to recreate the socket.


2801-2825: LGTM!

The getaddrinfo function correctly applies IDNA encoding to hostnames for internationalized domain name support, and properly validates port strings as UTF-8. This matches Python's behavior for hostname encoding.


234-275: These values are correctly defined per RFC 3542 standard and are the appropriate solution for macOS, where they are not available in the libc crate.