summaryrefslogtreecommitdiffstats
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-05-18 16:52:20 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-05-18 16:52:20 (GMT)
commit7a616f2fc5391f5899825a5e8fdc0d96ea6c7725 (patch)
tree0f0d55d5f6273efbb0562d08c363b76e0325a3ab /Lib/ssl.py
parentcc9ca223d62fdcf09f22d3cc8eb924cadba6d693 (diff)
parentb4410dbea699eb59358d3d61f45749173167d69a (diff)
downloadcpython-7a616f2fc5391f5899825a5e8fdc0d96ea6c7725.zip
cpython-7a616f2fc5391f5899825a5e8fdc0d96ea6c7725.tar.gz
cpython-7a616f2fc5391f5899825a5e8fdc0d96ea6c7725.tar.bz2
Issue #12065: connect_ex() on an SSL socket now returns the original errno
when the socket's timeout expires (it used to return None).
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index b7bb54b..f938dc9 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -443,7 +443,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
@@ -452,17 +452,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