Skip to content

gh-149454: Restore OS handler dispatch for custom URI schemes on macOS - #155859

Open
SomSamantray wants to merge 2 commits into
python:mainfrom
SomSamantray:gh-149454-macos-webbrowser-custom-scheme
Open

gh-149454: Restore OS handler dispatch for custom URI schemes on macOS#155859
SomSamantray wants to merge 2 commits into
python:mainfrom
SomSamantray:gh-149454-macos-webbrowser-custom-scheme

Conversation

@SomSamantray

@SomSamantray SomSamantray commented Aug 15, 2026

Copy link
Copy Markdown

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 stop file:// 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 like vscode:// or slack:// got pulled into the browser too, so webbrowser.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/https handling and named-browser dispatch are unchanged.

Lib/test/test_webbrowser.py gains coverage for the restored custom-scheme path (vscode://) and keeps the existing file:/http(s)/named-browser assertions passing. MacOSTest is darwin-gated and can't execute in this sandbox; behavior was additionally verified by forcing sys.platform == 'darwin' in a standalone script and confirming the exact /usr/bin/open invocation for http, https, file:, vscode:, slack:, and scheme-less inputs — CI's macOS job will run the real suite.

Fixes #149454.

Related: #128540, #130535

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python 3.14 webbrowser regression when launching vscode:// URI on macOS

1 participant