def sslwrap_simple(sock, keyfile=None, certfile=None):
 if hasattr(sock, '_sock'):
  sock = sock._sock
 ssl_sock = _ssl.sslwrap(sock, 0, keyfile, certfile, CERT_NONE, PROTOCOL_SSLv23, None)
 try:
  sock.getpeername()
 except:
  pass
 else:
  ssl_sock.do_handshake()
 return ssl_sock

def sslwrap_simple ( sock , keyfile = None , certfile = None ) : if hasattr ( sock , '_sock' ) : sock = sock . _sock ssl_sock = _ssl . sslwrap ( sock , 0 , keyfile , certfile , CERT_NONE , PROTOCOL_SSLv23 , None ) try : sock . getpeername ( ) except : pass else : ssl_sock . do_handshake ( ) return ssl_sock
a replacement for the old socket .