mirror of
https://github.com/python/cpython.git
synced 2026-10-28 10:25:05 +08:00
gh-154291: Fix socket.has_dualstack_ipv6() on DragonFly BSD (GH-154292)
On DragonFly BSD setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 0) succeeds without actually clearing the flag, so has_dualstack_ipv6() wrongly returned True. Verify with getsockopt() that IPV6_V6ONLY was cleared. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
96059f9446
commit
c7bbf040e7
2 files changed
+6
-1
No files matched your search
+3
-1
@@ -900,7 +900,9 @@ def has_dualstack_ipv6():
|
||||
try:
|
||||
with socket(AF_INET6, SOCK_STREAM) as sock:
|
||||
sock.setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 0)
|
||||
return True
|
||||
# On some platforms (e.g. DragonFly BSD) setting IPV6_V6ONLY to 0
|
||||
# silently has no effect, so check that it was actually cleared.
|
||||
return sock.getsockopt(IPPROTO_IPV6, IPV6_V6ONLY) == 0
|
||||
except error:
|
||||
return False
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Fix :func:`socket.has_dualstack_ipv6` to return ``False`` on platforms such as
|
||||
DragonFly BSD where setting ``IPV6_V6ONLY`` to 0 silently has no
|
||||
effect.
|
||||
Reference in new issue
Block a user