def _validate_ip(af, ip):
    '''
    Common logic for IPv4
    '''
    if af == socket.AF_INET6 and not socket.has_ipv6:
        raise RuntimeError('IPv6 not supported')
    try:
        socket.inet_pton(af, ip)
    except AttributeError:
        if af == socket.AF_INET6:
            raise RuntimeError('socket.inet_pton not available')
        try:
            socket.inet_aton(ip)
        except socket.error:
            return False
    except (socket.error, __HOLE__):
        return False
    return True
dataset/ETHPy150Open saltstack/salt/salt/utils/network.py/_validate_ip