[Python-checkins] r80507 - python/trunk/Lib/ssl.py

antoine.pitrou python-checkins at python.org
Mon Apr 26 19:23:33 CEST 2010


Author: antoine.pitrou
Date: Mon Apr 26 19:23:33 2010
New Revision: 80507

Log:
When calling getpeername() in SSLSocket.__init__, only silence exceptions
caused by the "socket not connected" condition.



Modified:
   python/trunk/Lib/ssl.py

Modified: python/trunk/Lib/ssl.py
==============================================================================
--- python/trunk/Lib/ssl.py	(original)
+++ python/trunk/Lib/ssl.py	Mon Apr 26 19:23:33 2010
@@ -78,6 +78,7 @@
 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 @@
         # 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:


More information about the Python-checkins mailing list