gh-149454: Restore OS handler dispatch for custom URI schemes on macOS - #155859
Open
SomSamantray wants to merge 2 commits into
Open
gh-149454: Restore OS handler dispatch for custom URI schemes on macOS#155859SomSamantray wants to merge 2 commits into
SomSamantray wants to merge 2 commits into
Conversation
…on macOS MacOS.open() forced every non-http(s) URL through the default browser's bundle ID (added in pythongh-130535 to fix file:// URLs opening in the wrong app). This over-generalized: custom app URI schemes like vscode:// or slack:// no longer reached their own registered handler, only the browser, a regression from 3.13. Narrow the bundle-ID override to file: URLs (the actual pythongh-128540 problem) and let the OS resolve the handler for every other non-http(s) scheme, as it did before 3.14.
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.
On macOS,
webbrowser.open()forced every non-http(s)URL through the default web browser via/usr/bin/open -b <bundle-id>, a change added in gh-130535 to stopfile://URLs opening in the OS's file-type handler (e.g. a text editor) instead of a browser. That fix overshot: application-specific URI schemes likevscode://orslack://got pulled into the browser too, sowebbrowser.open("vscode://...")opened the default web browser instead of the correct app — a regression from 3.13, where the OS's own scheme handler was invoked.This narrows the special-cased dispatch to
file:URLs only (the actual gh-128540 problem). Every other non-http(s)scheme now goes through plain/usr/bin/open <url>again, letting macOS resolve the scheme's own registered handler the way it did before 3.14.http/httpshandling and named-browser dispatch are unchanged.Lib/test/test_webbrowser.pygains coverage for the restored custom-scheme path (vscode://) and keeps the existingfile:/http(s)/named-browser assertions passing.MacOSTestis darwin-gated and can't execute in this sandbox; behavior was additionally verified by forcingsys.platform == 'darwin'in a standalone script and confirming the exact/usr/bin/openinvocation forhttp,https,file:,vscode:,slack:, and scheme-less inputs — CI's macOS job will run the real suite.Fixes #149454.
Related: #128540, #130535