]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
When calling getpeername() in SSLSocket.__init__, only silence exceptions
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 26 Apr 2010 17:23:33 +0000 (17:23 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 26 Apr 2010 17:23:33 +0000 (17:23 +0000)
caused by the "socket not connected" condition.

Lib/ssl.py

index 1d29bef72d62062d7ab14397eab1ed9c23bfdcf5..bfeb559f82c2b5cc0f74fdf3f20b3df30d4b8054 100644 (file)
@@ -78,6 +78,7 @@ from _ssl import \
 from socket import socket, _fileobject, _delegate_methods, error as socket_error
 from socket import getnameinfo as _getnameinfo
 import base64        # for DER-to-PEM translation
+import errno
 
 class SSLSocket(socket):
 
@@ -105,7 +106,9 @@ class SSLSocket(socket):
         # see if it's connected
         try:
             socket.getpeername(self)
-        except socket_error:
+        except socket_error, e:
+            if e.errno != errno.ENOTCONN:
+                raise
             # no, no connection yet
             self._sslobj = None
         else: