From 3018cf8af6a2287a25b7c94b3cd1ea13ac857478 Mon Sep 17 00:00:00 2001 From: Damian Shaw Date: Wed, 11 Nov 2026 19:01:45 -0500 Subject: [PATCH] gh-161763: Correct SSL docs for unconnected client sockets (#GH-61772) * gh-161763: Correct SSL docs for unconnected client sockets * gh-161763: Qualify SSL socket method references (cherry picked from commit f112215dd7ef054655093e880384dbaed0fbfc66) Co-authored-by: Damian Shaw --- Doc/library/ssl.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst index 7ab6f9b749364f..31de505a9b1884 100644 --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -104,6 +104,7 @@ Client socket example with custom context and IPv4:: with socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) as sock: with context.wrap_socket(sock, server_hostname=hostname) as ssock: + ssock.connect((hostname, 443)) print(ssock.version()) @@ -1823,13 +1824,12 @@ to speed up repeated connections from the same clients. The parameter ``server_side`` is a boolean which identifies whether server-side or client-side behavior is desired from this socket. - For client-side sockets, the context construction is lazy; if the - underlying socket isn't connected yet, the context construction will be - performed after :meth:`connect` is called on the socket. For - server-side sockets, if the socket has no remote peer, it is assumed + For client-side sockets, if *sock* is not yet connected, the underlying + SSL object is created when :meth:`~socket.socket.connect` is called. + For server-side sockets, if the socket has no remote peer, it is assumed to be a listening socket, and the server-side SSL wrapping is automatically performed on client connections accepted via the - :meth:`accept` method. The method may raise :exc:`SSLError`. + :meth:`~socket.socket.accept` method. The method may raise :exc:`SSLError`. On client connections, the optional parameter *server_hostname* specifies the hostname of the service which we are connecting to. This allows a