Skip to content

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

Description

@skissane-medallia

Bug report

Bug description:

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

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Activity

  1. 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
  2. skissane-medallia commented on May 6, 2026

    @skissane-medallia
    Author

    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.

  3. edvilme commented on May 6, 2026

    @edvilme
    Contributor

    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
  4. added
    stdlibStandard Library Python modules in the Lib/ directory
    3.14bugs and security fixes
    3.15bugs and security fixes
    type-bugAn unexpected behavior, bug, or error
    and removed
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    on May 6, 2026
  5. skissane-medallia commented on May 6, 2026

    @skissane-medallia
    Author

    @edvilme

    open vscode:// opens VSCode

    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.

  6. skissane-medallia commented on May 6, 2026

    @skissane-medallia
    Author

    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.

  7. skissane-medallia commented on May 7, 2026

    @skissane-medallia
    Author

    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
  8. encukou commented on May 8, 2026

    @encukou
    Member

    webbrowser did not open a browser before? Sorry, but that sounds like a fixed bug.

  9. added
    pendingThe issue will be closed if no feedback is provided
    on May 8, 2026
  10. skissane-medallia commented on May 13, 2026

    @skissane-medallia
    Author

    @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.

  11. florentx commented on May 26, 2026

    @florentx
    Contributor

    Observed behavior is probably related to this recent change

    This is related, but not the cause of the behavior. Sorry for noise:

  12. added a commit that references this issue on Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15bugs and security fixespendingThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions