mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #12065: connect_ex() on an SSL socket now returns the original errno
when the socket's timeout expires (it used to return None).
This commit is contained in:
parent
3349bca46d
commit
b4410dbea6
3 changed files with 45 additions and 11 deletions
24
Lib/ssl.py
24
Lib/ssl.py
|
@ -442,7 +442,7 @@ class SSLSocket(socket):
|
|||
finally:
|
||||
self.settimeout(timeout)
|
||||
|
||||
def _real_connect(self, addr, return_errno):
|
||||
def _real_connect(self, addr, connect_ex):
|
||||
if self.server_side:
|
||||
raise ValueError("can't connect in server-side mode")
|
||||
# Here we assume that the socket is client-side, and not
|
||||
|
@ -451,17 +451,19 @@ class SSLSocket(socket):
|
|||
raise ValueError("attempt to connect already-connected SSLSocket!")
|
||||
self._sslobj = self.context._wrap_socket(self, False, self.server_hostname)
|
||||
try:
|
||||
socket.connect(self, addr)
|
||||
if self.do_handshake_on_connect:
|
||||
self.do_handshake()
|
||||
except socket_error as e:
|
||||
if return_errno:
|
||||
return e.errno
|
||||
if connect_ex:
|
||||
rc = socket.connect_ex(self, addr)
|
||||
else:
|
||||
self._sslobj = None
|
||||
raise e
|
||||
self._connected = True
|
||||
return 0
|
||||
rc = None
|
||||
socket.connect(self, addr)
|
||||
if not rc:
|
||||
if self.do_handshake_on_connect:
|
||||
self.do_handshake()
|
||||
self._connected = True
|
||||
return rc
|
||||
except socket_error:
|
||||
self._sslobj = None
|
||||
raise
|
||||
|
||||
def connect(self, addr):
|
||||
"""Connects to remote ADDR, and then wraps the connection in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue