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-128540: lookup default webbrowser on Windows#130538

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

Open
minrk wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromminrk:default-browser-windows

Conversation

@minrk
Copy link
Contributor

@minrkminrk commentedFeb 25, 2025
edited
Loading

lookup default browsers viaUrlAssociations\https\UserChoice if protocol is not http/https. ensureswebbrowser.open launches a web browser on Windows, even for URLs that are not http[s]. Only does the lookup for non-http URLs, limiting the impact of the change.

ensures browser is opened for e.g.file:// URLs, wherestartfile opens file by association. Launching custom protocols explicitly goes through the browser instead of throughstartfile. The end result isusually the same, after a prompt, unless the browser has explicit support/configuration for the protocol. Alternative: only lookup forfile:// instead ofnothttp[s]://.

Added extremely basic test exercise, the registry lookups are not actually covered, but I have tested them by hand. I'm not sure how to write good tests for the registry stuff.

Addressesgh-128540 on Windows only.

Open questions:

  • custom URLs:os.startfile("ssh://some-host") might start putty or something, whereas this explicitly launches the browser (which would in turn typically prompt "launch external application PuTTy..?"). Behavior for custom URLs is previously undefined and inconsistent, but after this PR, it consistently launches a webbrowser if it can, but remainsundefined.
  • are there more ways/times/versions for this to fail? It works in my tests, but I don't know all the different situations on Windows wrt versions, permissions, UWP, etc.
  • Can theopen command-line lack%1 and still be valid (e.g. withappend)? I can't find a spec for this, so it would be good to know. I've gone with the most conservative, which is to assume it doesn't work if%1 is not present, falling back on previousos.startfile in that case.

Links:

lookup default browsers via `UrlAssociations\https\UserChoice` if protocol is not http/httpsensures browser is opened for e.g. file:// URLs
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@minrk

[8]ページ先頭

©2009-2025 Movatter.jp