def allowed_gai_family():
 family = socket.AF_INET
 if HAS_IPV6:
  family = socket.AF_UNSPEC
 return family

def allowed_gai_family ( ) : family = socket . AF_INET if HAS_IPV6 : family = socket . AF_UNSPEC return family
this function is designed to work in the context of getaddrinfo .