You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python 3.14 webbrowser regression when launching vscode:// URI on macOS #149454
In Python 3.13.13 on macOS 26.3.1, I run __import__("webbrowser").open("vscode://"): it opens Microsoft VS Code
Same machine, in Python 3.14.2, same code: opens Chrome instead
I observe the same behaviour with Python 3.15.0a8
One line test case (using uv):
uv run --no-project --python=3.14 python3 -c '__import__("webbrowser").open("vscode://")'
In my actual use case, the URI is more complex, something like vscode://vscode-remote/ssh-remote+MYDEVBOX.example.com/workspaces/MYPROJECT.code-workspace – but vscode:// is enough to reproduce it
changed the title [-]Python 3.14 webbrowser regression when launching vscode:// URI[/-][+]Python 3.14 webbrowser regression when launching vscode:// URI on macOS[/+]on May 6, 2026
From looking at the code, I believe this was introduced by #130535 – that PR appears to assume you only ever want to open custom URI schemes in an actual web browser. But in reality, for an application-specific URI scheme such as vscode:// or slack://, the browser probably doesn't know how to handle it, the OS-registered application does.
That is most likely an issue with your browser not knowing how to handle the application-specific URI
When it opens Chrome, what does it show? Also, what happens if you attempt to open the URI from the terminal?
open vscode://vscode-remote/ssh-remote+MYDEVBOX.example.com/workspaces/MYPROJECT.code-workspace
uv run --no-project --python=3.13.13 python3 -m webbrowser vscode:// opens VSCode
uv run --no-project --python=3.14.2 python3 -m webbrowser vscode://:
If Google Chrome is not running, it starts Chrome (I am using 148.0.7778.97) – but unusually, it starts it with no windows open
If Chrome is already running, it makes it the foreground app, showing me whatever window/tab I was last using
Note, Chrome does understand vscode:// if I type it into the URL bar, or link to it from a web page – it looks up the application in the OS settings, and displays a confirmation box "Open Visual Studio Code? A website wants to open this application"
But I think, for security reasons, it silently ignores URIs handled by other apps if passed to it directly – because it isn't expecting anyone to do that.
The behaviour depends on which web browser is configured as default:
Google Chrome: opens/foregrounds Chrome, but URL is silently ignored
Safari: shows a confirmation box asking if you want to open the app "Visual Studio Code" (this is a behaviour change from <=3.13 where Safari did not open and no confirmation box was displayed – it is confusing to display a confirmation box asking if a website wants to open an app when a Python script on your machine is trying to open it)
Firefox: behaves like Safari does, mostly
If I understand the logic behind #130535, people didn't like the fact that file:// opened a text editor instead of browser on some systems. Fair enough, but I don't think changing the behaviour of custom URI schemes to route through the browser was necessary to fix a problem with file:// in particular.
In case it is of assistance to anyone, below is a monkeypatch-workaround for this bug (which Claude Code wrote for me):
"""Workaround for https://github.com/python/cpython/issues/149454.In Python 3.14 on macOS, webbrowser.open() incorrectly routes non-browser URIschemes (e.g. vscode://, slack://) to the default web browser instead of themacOS `open` command. Calling apply() monkeypatches webbrowser.open to restorethe pre-3.14 behaviour for those schemes."""importsubprocessimportsysimporturllib.parseimportwebbrowser_BROWSER_SCHEMES=frozenset({"http", "https", "file"})
_original_open=Nonedef_patched_open(url, new=0, autoraise=True):
scheme=urllib.parse.urlparse(url).schemeifschemein_BROWSER_SCHEMES:
return_original_open(url, new=new, autoraise=autoraise)
subprocess.run(["open", url], check=False)
returnTruedefapply() ->None:
"""Apply the webbrowser.open monkeypatch if running on the affected platform."""global_original_openifsys.platform=="darwin"andsys.version_info[:2] == (3, 14):
_original_open=webbrowser.openwebbrowser.open=_patched_open
@encukou Why should webbrowser open a web browser if passed a URL scheme which a web browser can't handle? It has supported such URL schemes for a very long time, and it still does on other platforms.
How is it a "fixed bug" if code which used to work no longer does anything useful? On macOS with Chrome as your default browser, webbrowser.open() passed a custom app URI used to open the custom app, now it just opens Google Chrome; the former behaviour is useful, the new behaviour is useless.
Also, if you come from a Java background (as I do), it is natural to view webbrowser.open as the equivalent of Java's java.awt.Desktop.browse(URI), which is explicitly documented as invoking a browser if the browser supports the URI scheme, and invoking the registered application otherwise:
Launches the default browser to display a URI. If the default browser is not able to handle the specified URI, the application registered for handling URIs of the specified type is invoked. The application is determined from the protocol and path of the URI, as defined by the URI class.
Python's webbrowser didn't document support of URI schemes that the browser doesn't support – but it never said it didn't support them either – and until Python 3.14, it worked; and even on Python 3.14, it still does, if you aren't using macOS with Chrome as your default browser.
Activity
[-]Python 3.14 webbrowser regression when launching vscode:// URI[/-][+]Python 3.14 webbrowser regression when launching vscode:// URI on macOS[/+]skissane-medallia commentedon May 6, 2026
From looking at the code, I believe this was introduced by #130535 – that PR appears to assume you only ever want to open custom URI schemes in an actual web browser. But in reality, for an application-specific URI scheme such as
vscode://orslack://, the browser probably doesn't know how to handle it, the OS-registered application does.edvilme commentedon May 6, 2026
That is most likely an issue with your browser not knowing how to handle the application-specific URI
When it opens Chrome, what does it show? Also, what happens if you attempt to open the URI from the terminal?
skissane-medallia commentedon May 6, 2026
@edvilme
open vscode://opens VSCodeuv run --no-project --python=3.13.13 python3 -m webbrowser vscode://opens VSCodeuv run --no-project --python=3.14.2 python3 -m webbrowser vscode://:Note, Chrome does understand
vscode://if I type it into the URL bar, or link to it from a web page – it looks up the application in the OS settings, and displays a confirmation box "Open Visual Studio Code? A website wants to open this application"But I think, for security reasons, it silently ignores URIs handled by other apps if passed to it directly – because it isn't expecting anyone to do that.
skissane-medallia commentedon May 6, 2026
The behaviour depends on which web browser is configured as default:
If I understand the logic behind #130535, people didn't like the fact that
file://opened a text editor instead of browser on some systems. Fair enough, but I don't think changing the behaviour of custom URI schemes to route through the browser was necessary to fix a problem withfile://in particular.skissane-medallia commentedon May 7, 2026
In case it is of assistance to anyone, below is a monkeypatch-workaround for this bug (which Claude Code wrote for me):
encukou commentedon May 8, 2026
webbrowserdid not open a browser before? Sorry, but that sounds like a fixed bug.skissane-medallia commentedon May 13, 2026
@encukou Why should
webbrowseropen a web browser if passed a URL scheme which a web browser can't handle? It has supported such URL schemes for a very long time, and it still does on other platforms.How is it a "fixed bug" if code which used to work no longer does anything useful? On macOS with Chrome as your default browser,
webbrowser.open()passed a custom app URI used to open the custom app, now it just opens Google Chrome; the former behaviour is useful, the new behaviour is useless.Also, if you come from a Java background (as I do), it is natural to view
webbrowser.openas the equivalent of Java'sjava.awt.Desktop.browse(URI), which is explicitly documented as invoking a browser if the browser supports the URI scheme, and invoking the registered application otherwise:Python's
webbrowserdidn't document support of URI schemes that the browser doesn't support – but it never said it didn't support them either – and until Python 3.14, it worked; and even on Python 3.14, it still does, if you aren't using macOS with Chrome as your default browser.florentx commentedon May 26, 2026
Observed behavior is probably related to this recent changeThis is related, but not the cause of the behavior. Sorry for noise:
Merge branch 'main' into pythongh-149454-macos-webbrowser-custom-scheme