def supports_ipv6():
 if ((not socket.has_ipv6) or (not hasattr(socket, 'AF_INET6'))):
  return False
 try:
  sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
  with contextlib.closing(sock):
   sock.bind(('::1', 0))
  return True
 except socket.error:
  return False

def supports_ipv6 ( ) : if ( ( not socket . has_ipv6 ) or ( not hasattr ( socket , 'AF_INET6' ) ) ) : return False try : sock = socket . socket ( socket . AF_INET6 , socket . SOCK_STREAM ) with contextlib . closing ( sock ) : sock . bind ( ( '::1' , 0 ) ) return True except socket . error : return False
return true if ipv6 is supported on this platform .