Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
GH-123599:url2pathname()
: don't callgethostbyname()
by default#132610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…faultFollow-up to 0879ebc.Add *resolve_netloc* keyword-only argument to `url2pathname()`, defaultingto false. When set to true, we call `socket.gethostbyname()` to resolvethe URL authority (netloc).
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@@ -1494,6 +1494,8 @@ def _is_local_authority(authority): | |||
if authority == hostname: | |||
return True | |||
# Compare IP addresses | |||
if not resolve: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I wonder, should we check this before callinggethostname()
which can fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm struggling to come up with firm info on whengethostname()
fails (or whether it can perform network access). Do you have any pointers? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I do not know.
But I was thinking about this case: processing the "file:" URL on different computer. We cannot usegethostname()
, because it returns a different result. If we want to get a path onother computer, we should ignore the host name. There will still be problem with processing Windows paths on Posix and Posix paths on Windows.
I do not know how common this case, and how common the opposite case, when we only usegethostname()
, but notgethostbyname()
. We should guess what would be more useful for users without having any data.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Library/2024-11-14-21-17-48.gh-issue-126838.Yr5vKF.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Thanks for the reviews - sorry for my slow response |
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Library/2024-11-14-21-17-48.gh-issue-126838.Yr5vKF.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
@serhiy-storchaka sorry for the short notice, but would you mind if I merge this in time for 3.14 beta 1? I can log youroutstanding feedback as a follow-up issue; I suspect we can address it during the 3.14 beta period without affecting the API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM.
I do not actually know what to do when we want to parse the "file:" URL on different machine, especially if they are Windows and Posix. On Windows, we can always interpret the host name as a UNC path. On Posix we can only ignore it or raise an exception if it is not localhost.
bedevere-bot commentedMay 5, 2025
🤖 New build scheduled with the buildbot fleet by@barneygale for commit2a42d88 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F132610%2Fmerge If you want to schedule another build, you need to add the🔨 test-with-buildbots label again. |
8e08ac9
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Follow-up to66cdb2b.
Addresolve_host keyword-only argument to
url2pathname()
, defaulting to false. When set to true, we callsocket.gethostbyname()
to resolve the URL authority (netloc).Path.from_uri()
doesn't work if the URI contains host component #123599