Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
barneygale merged 10 commits intopython:mainfrombarneygale:gh-123599-resolve-netloc
May 5, 2025

Conversation

barneygale
Copy link
Contributor

@barneygalebarneygale commentedApr 16, 2025
edited
Loading

Follow-up to66cdb2b.

Addresolve_host keyword-only argument tourl2pathname(), defaulting to false. When set to true, we callsocket.gethostbyname() to resolve the URL authority (netloc).

…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).
@@ -1494,6 +1494,8 @@ def _is_local_authority(authority):
if authority == hostname:
return True
# Compare IP addresses
if not resolve:

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?

Copy link
ContributorAuthor

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.

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.

barneygaleand others added2 commitsApril 28, 2025 17:48
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>
@barneygale
Copy link
ContributorAuthor

Thanks for the reviews - sorry for my slow response

barneygaleand others added2 commitsMay 5, 2025 12:52
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
@barneygale
Copy link
ContributorAuthor

@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.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a 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.

barneygale and zooba reacted with thumbs up emoji
@barneygalebarneygale added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelMay 5, 2025
@bedevere-bot
Copy link

🤖 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.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelMay 5, 2025
@barneygalebarneygaleenabled auto-merge (squash)May 5, 2025 16:41
@barneygalebarneygale merged commit8e08ac9 intopython:mainMay 5, 2025
39 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@zoobazoobazooba left review comments

@AA-TurnerAA-TurnerAA-Turner left review comments

@picnixzpicnixzpicnixz left review comments

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@barneygale@bedevere-bot@zooba@serhiy-storchaka@AA-Turner@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp