Repository navigation
Python 3.14 webbrowser regression when launching vscode:// URI on macOS #149454
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on May 6, 2026 - 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://orslack://, 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
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errorand removedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errorstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on May 6, 2026 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://:- 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.
Reacted by NTFSvolumeThe 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 withfile://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 URI schemes (e.g. vscode://, slack://) to the default web browser instead of the macOS `open` command. Calling apply() monkeypatches webbrowser.open to restore the pre-3.14 behaviour for those schemes. """ import subprocess import sys import urllib.parse import webbrowser _BROWSER_SCHEMES = frozenset({"http", "https", "file"}) _original_open = None def _patched_open(url, new=0, autoraise=True): scheme = urllib.parse.urlparse(url).scheme if scheme in _BROWSER_SCHEMES: return _original_open(url, new=new, autoraise=autoraise) subprocess.run(["open", url], check=False) return True def apply() -> None: """Apply the webbrowser.open monkeypatch if running on the affected platform.""" global _original_open if sys.platform == "darwin" and sys.version_info[:2] == (3, 14): _original_open = webbrowser.open webbrowser.open = _patched_open
webbrowserdid not open a browser before? Sorry, but that sounds like a fixed bug.Reacted by Zachary Ware- addedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on May 8, 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: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
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.Observed behavior is probably related to this recent changeThis is related, but not the cause of the behavior. Sorry for noise:
Bug report
Bug description:
In Python 3.13.13 on macOS 26.3.1, I run
__import__("webbrowser").open("vscode://"): it opens Microsoft VS CodeSame 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):In my actual use case, the URI is more complex, something like
vscode://vscode-remote/ssh-remote+MYDEVBOX.example.com/workspaces/MYPROJECT.code-workspace– butvscode://is enough to reproduce itCPython versions tested on:
3.14
Operating systems tested on:
macOS
Linked PRs