diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 3101afad362..2f9555ad60d 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -32,7 +32,7 @@ def register(name, klass, instance=None, *, preferred=False): # Preferred browsers go to the front of the list. # Need to match to the default browser returned by xdg-settings, which # may be of the form e.g. "firefox.desktop". - if preferred or (_os_preferred_browser and name in _os_preferred_browser): + if preferred or (_os_preferred_browser and f'{name}.desktop' == _os_preferred_browser): _tryorder.insert(0, name) else: _tryorder.append(name) diff --git a/Misc/NEWS.d/next/Library/2023-12-12-15-19-58.gh-issue-108172.KyDPuG.rst b/Misc/NEWS.d/next/Library/2023-12-12-15-19-58.gh-issue-108172.KyDPuG.rst new file mode 100644 index 00000000000..5c6b9cd3f81 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-12-12-15-19-58.gh-issue-108172.KyDPuG.rst @@ -0,0 +1 @@ +``webbrowser`` honors OS preferred browser on Linux when its desktop entry name contains the text of a known browser name.