def is_ipv6_supported():
    has_ipv6_support = socket.has_ipv6
    try:
        s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
        s.close()
    except socket.error as e:
        if (e.errno == errno.EAFNOSUPPORT):
            has_ipv6_support = False
        else:
            raise
    if (has_ipv6_support and sys.platform.startswith('linux')):
        try:
            with open('/proc/net/if_inet6') as f:
                if (not f.read()):
                    has_ipv6_support = False
        except IOError:
            has_ipv6_support = False
    return has_ipv6_support
def is_ipv6_supported():
    has_ipv6_support = socket.has_ipv6
    try:
        s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
        s.close()
    except socket.error as e:
        if (e.errno == errno.EAFNOSUPPORT):
            has_ipv6_support = False
        else:
            raise
    if (has_ipv6_support and sys.platform.startswith('linux')):
        try:
            with open('/proc/net/if_inet6') as f:
                if (not f.read()):
                    has_ipv6_support = False
        except IOError:
            has_ipv6_support = False
    return has_ipv6_support