Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
test_SocketType_resolve fails #580
Apparently on Mac, on some setups,
This is probably a system configuration issue and maybe there is not much we can do about it. But it's causing our tests to fail on some machines. I've seen this happen regularly on my work laptop for some time (macOS 10.13.5, Python 3.6 and 3.7) and a couple other sprinters at EuroPython had the same issue. Good news is that it doesn't affect our Mac CI.
One potential (maybe not ideal) solution is to verify whether the system has this quirk and in that case skip the test.
Calling getaddrinfo() on an IPv4 address, with AF_INET6 and the AI_V4MAPPED flag returns an IPv4-mapped IPv6 address. This is documented and works in all platforms.
>>> getaddrinfo('220.127.116.11', 0, AF_INET6, SOCK_STREAM, 0, AI_V4MAPPED) [(<AddressFamily.AF_INET6: 30>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('::ffff:18.104.22.168', 0, 0, 0))]
If I only want IPv6 addresses I won't set the AI_V4MAPPED and I won't get any result back. For example, this is what happens on Linux:
But if I try the same on my Mac I still get the IPv4-mapped results, even though I shouldn't!
>>> getaddrinfo('22.214.171.124', 0, AF_INET6, SOCK_STREAM, 0, 0) [(<AddressFamily.AF_INET6: 30>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('::ffff:126.96.36.199', 0, 0, 0))]
(I'm trying to figure out whether we should just relax the test, or if we should do some fixups in our
I tried disabling the interface that had a default route configured on (I thought it might be a hack introduced to make v6 operations smoother for some applications) but the result is the same. Must be noted that I can't (or don't know how to) disable ::1
Okay, that's good to know...
Another question: what do you get for:
getaddrinfo("facebook.com", 0, family=socket.AF_INET6, type=socket.SOCK_STREAM) getaddrinfo("vorpus.org", 0, family=socket.AF_INET6, type=socket.SOCK_STREAM)
? (That's one site that resolves to both an ipv4 and an ipv6, and one that resolves to just an ipv4.)
Looking at the test more closely, I guess it is actually testing a real thing – when you have a
getaddrinfo(host, port, sock.family, sock.type, sock.proto, flags)
This is a pretty edge case-y kind of thing – it looks like the stdlib's version of this code never passes
referenced this issue
Jul 31, 2018
OK, I thought hard about adding a real workaround, but I don't think it's worth it given that:
So here's a patch to disable that test on buggy systems, and then we can close this: #589
If it does start causing actual problems for someone, we can re-open this. Working around it should be fairly straightforward: you can detect an IPv4-mapped address with