def ssl_wrap_socket(socket, ssl_options, server_hostname=None, **kwargs):
 context = ssl_options_to_context(ssl_options)
 if (hasattr(ssl, 'SSLContext') and isinstance(context, ssl.SSLContext)):
  if ((server_hostname is not None) and getattr(ssl, 'HAS_SNI')):
   return context.wrap_socket(socket, server_hostname=server_hostname, **kwargs)
  else:
   return context.wrap_socket(socket, **kwargs)
 else:
  return ssl.wrap_socket(socket, **dict(context, **kwargs))

def ssl_wrap_socket ( socket , ssl_options , server_hostname = None , ** kwargs ) : context = ssl_options_to_context ( ssl_options ) if ( hasattr ( ssl , 'SSLContext' ) and isinstance ( context , ssl . SSLContext ) ) : if ( ( server_hostname is not None ) and getattr ( ssl , 'HAS_SNI' ) ) : return context . wrap_socket ( socket , server_hostname = server_hostname , ** kwargs ) else : return context . wrap_socket ( socket , ** kwargs ) else : return ssl . wrap_socket ( socket , ** dict ( context , ** kwargs ) )
returns an ssl .