gh-59060: Support IPv6 in logging.handlers.DatagramHandler#154496
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-59060: Support IPv6 in logging.handlers.DatagramHandler#154496serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
It always created an IPv4 socket, so sending to an IPv6 address failed and the log record was silently lost. Create a socket of the family of the resolved address if the host has no IPv4 address. Also add a timeout to the waits in DatagramHandlerTest. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DatagramHandleralways created an IPv4 socket, so it could not send to an IPv6 address.Sending to
::1failed withgaierror(-9, 'Address family for hostname not supported'), and sinceemit()passes such errors tohandleError(), the log record was silently lost. This is why the problem went unnoticed for so long.The socket family is now taken from the resolved address, but only if the host has no IPv4 address, so on dual-stack hosts an IPv4 socket is still created as before. Resolution errors are left to
sendto().SocketHandler(which usessocket.create_connection()) andSysLogHandler(which iterates oversocket.getaddrinfo()results) already support IPv6, soDatagramHandlerwas the only remaining gap.The new
IPv6DatagramHandlerTestmirrors the existingIPv6SysLogHandlerTest; it fails without the fix and passes with it. The waits inDatagramHandlerTestgot a timeout, because otherwise a failure hangs the test instead of reporting it.🤖 Generated with Claude Code