Repository navigation
Do not retry numeric-only getaddrinfo failures - #3535
Open
Cherith1222 wants to merge 1 commit into
Open
Cherith1222 wants to merge 1 commit into
Cherith1222 wants to merge 1 commit into
Conversation
When the caller already passes AI_NUMERICHOST|AI_NUMERICSERV, the non-blocking fast-path call is identical to the retry, so propagate its EAI_NONAME instead of calling the custom hostname resolver or a worker thread. Fixes python-trio#1249. AI-assisted (Cursor); not yet reviewed by a human.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3535 +/- ##
====================================================
- Coverage 100.00000% 99.99487% -0.00513%
====================================================
Files 128 128
Lines 19474 19485 +11
Branches 1323 1323
====================================================
+ Hits 19474 19484 +10
- Misses 0 1 +1
🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Summary
trio.socket.getaddrinforetried a numeric lookup in a worker thread, or called the custom hostname resolver, after the non-blocking attempt failed withEAI_NONAME. When the caller already passedAI_NUMERICHOST|AI_NUMERICSERV, that retry is the same lookup. TheEAI_NONAMEerror is now raised directly.Fixes #1249.
newsfragments/1249.bugfix.rstis in the commit.Test Plan
On Windows, Python 3.13,
PYTHONPATH=src:pytest src/trio/_tests/test_socket.py -k "numeric_only_flags or custom_hostname_resolver or idna" -p no:cacheprovider -q→ before the change, 1 failed and 2 passed; after, 3 passed.src/trio/_tests/test_socket.py→ 31 passed, 4 skipped (Linux-only, two--run-slowtests, and no Unix domain socket).Not run: slow tests, the rest of the suite, the type check, and non-Windows platforms.
AI assistance
Drafted with Cursor. The account owner authorized opening this pull request. Cherith reviewed this diff and confirmed it with the person who helped draft it. There is no
Co-authored-by,Reviewed-by, orSigned-off-bytrailer.