def _has_ipv6(host):
 sock = None
 has_ipv6 = False
 if socket.has_ipv6:
  try:
   sock = socket.socket(socket.AF_INET6)
   sock.bind((host, 0))
   has_ipv6 = True
  except Exception:
   pass
 if sock:
  sock.close()
 return has_ipv6

def _has_ipv6 ( host ) : sock = None has_ipv6 = False if socket . has_ipv6 : try : sock = socket . socket ( socket . AF_INET6 ) sock . bind ( ( host , 0 ) ) has_ipv6 = True except Exception : pass if sock : sock . close ( ) return has_ipv6
returns true if the system can bind an ipv6 address .