From b04087c7435fb4a8cb9c638be3168aab95be2ed9 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 22 Mar 2023 01:54:55 +1100 Subject: [PATCH 1/9] Remove obsolete browsers and test from webbrowser --- Doc/library/webbrowser.rst | 10 +---- Lib/test/test_webbrowser.py | 31 ++----------- Lib/webbrowser.py | 86 ++++++------------------------------- 3 files changed, 16 insertions(+), 111 deletions(-) diff --git a/Doc/library/webbrowser.rst b/Doc/library/webbrowser.rst index 734b6321e5a7e7..65b521a4b7fb66 100644 --- a/Doc/library/webbrowser.rst +++ b/Doc/library/webbrowser.rst @@ -115,11 +115,7 @@ for the controller classes, all defined in this module. +------------------------+-----------------------------------------+-------+ | ``'firefox'`` | :class:`Mozilla('mozilla')` | | +------------------------+-----------------------------------------+-------+ -| ``'netscape'`` | :class:`Mozilla('netscape')` | | -+------------------------+-----------------------------------------+-------+ -| ``'galeon'`` | :class:`Galeon('galeon')` | | -+------------------------+-----------------------------------------+-------+ -| ``'epiphany'`` | :class:`Galeon('epiphany')` | | +| ``'epiphany'`` | :class:`Epiphany('epiphany')` | | +------------------------+-----------------------------------------+-------+ | ``'skipstone'`` | :class:`BackgroundBrowser('skipstone')` | | +------------------------+-----------------------------------------+-------+ @@ -129,12 +125,8 @@ for the controller classes, all defined in this module. +------------------------+-----------------------------------------+-------+ | ``'kfm'`` | :class:`Konqueror()` | \(1) | +------------------------+-----------------------------------------+-------+ -| ``'mosaic'`` | :class:`BackgroundBrowser('mosaic')` | | -+------------------------+-----------------------------------------+-------+ | ``'opera'`` | :class:`Opera()` | | +------------------------+-----------------------------------------+-------+ -| ``'grail'`` | :class:`Grail()` | | -+------------------------+-----------------------------------------+-------+ | ``'links'`` | :class:`GenericBrowser('links')` | | +------------------------+-----------------------------------------+-------+ | ``'elinks'`` | :class:`Elinks('elinks')` | | diff --git a/Lib/test/test_webbrowser.py b/Lib/test/test_webbrowser.py index 9d608d63a01ed3..147a113c7fd730 100644 --- a/Lib/test/test_webbrowser.py +++ b/Lib/test/test_webbrowser.py @@ -11,7 +11,7 @@ if not support.has_subprocess_support: raise unittest.SkipTest("test webserver requires subprocess") -URL = 'http://www.example.com' +URL = 'https://www.example.com' CMD_NAME = 'test' @@ -120,34 +120,9 @@ def test_open_new_tab(self): arguments=['-new-tab', URL]) -class NetscapeCommandTest(CommandTestMixin, unittest.TestCase): +class EpiphanyCommandTest(CommandTestMixin, unittest.TestCase): - browser_class = webbrowser.Netscape - - def test_open(self): - self._test('open', - options=['-raise', '-remote'], - arguments=['openURL({})'.format(URL)]) - - def test_open_with_autoraise_false(self): - self._test('open', kw=dict(autoraise=False), - options=['-noraise', '-remote'], - arguments=['openURL({})'.format(URL)]) - - def test_open_new(self): - self._test('open_new', - options=['-raise', '-remote'], - arguments=['openURL({},new-window)'.format(URL)]) - - def test_open_new_tab(self): - self._test('open_new_tab', - options=['-raise', '-remote'], - arguments=['openURL({},new-tab)'.format(URL)]) - - -class GaleonCommandTest(CommandTestMixin, unittest.TestCase): - - browser_class = webbrowser.Galeon + browser_class = webbrowser.Epiphany def test_open(self): self._test('open', diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index a56ff33dbbdc69..0191533a401838 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -292,19 +292,8 @@ class Mozilla(UnixBrowser): background = True -class Netscape(UnixBrowser): - """Launcher class for Netscape browser.""" - - raise_opts = ["-noraise", "-raise"] - remote_args = ['-remote', 'openURL(%s%action)'] - remote_action = "" - remote_action_newwin = ",new-window" - remote_action_newtab = ",new-tab" - background = True - - -class Galeon(UnixBrowser): - """Launcher class for Galeon/Epiphany browsers.""" +class Epiphany(UnixBrowser): + """Launcher class for Epiphany browser.""" raise_opts = ["-noraise", ""] remote_args = ['%action', '%s'] @@ -401,45 +390,6 @@ def open(self, url, new=0, autoraise=True): else: return (p.poll() is None) - -class Grail(BaseBrowser): - # There should be a way to maintain a connection to Grail, but the - # Grail remote control protocol doesn't really allow that at this - # point. It probably never will! - def _find_grail_rc(self): - import glob - import pwd - import socket - import tempfile - tempdir = os.path.join(tempfile.gettempdir(), - ".grail-unix") - user = pwd.getpwuid(os.getuid())[0] - filename = os.path.join(glob.escape(tempdir), glob.escape(user) + "-*") - maybes = glob.glob(filename) - if not maybes: - return None - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - for fn in maybes: - # need to PING each one until we find one that's live - try: - s.connect(fn) - except OSError: - # no good; attempt to clean it out, but don't fail: - try: - os.unlink(fn) - except OSError: - pass - else: - return s - - def _remote(self, action): - s = self._find_grail_rc() - if not s: - return 0 - s.send(action) - s.close() - return 1 - def open(self, url, new=0, autoraise=True): sys.audit("webbrowser.open", url) if new: @@ -475,31 +425,25 @@ def register_X_browsers(): if "KDE_FULL_SESSION" in os.environ and shutil.which("kfmclient"): register("kfmclient", Konqueror, Konqueror("kfmclient")) + # Common symbolic link for the default text-based browser if shutil.which("x-www-browser"): register("x-www-browser", None, BackgroundBrowser("x-www-browser")) # The Mozilla browsers - for browser in ("firefox", "iceweasel", "iceape", "seamonkey"): + for browser in ("firefox", "iceweasel", "seamonkey", "mozilla-firefox", + "mozilla"): if shutil.which(browser): register(browser, None, Mozilla(browser)) - # The Netscape and old Mozilla browsers - for browser in ("mozilla-firefox", - "mozilla-firebird", "firebird", - "mozilla", "netscape"): - if shutil.which(browser): - register(browser, None, Netscape(browser)) - # Konqueror/kfm, the KDE browser. if shutil.which("kfm"): register("kfm", Konqueror, Konqueror("kfm")) elif shutil.which("konqueror"): register("konqueror", Konqueror, Konqueror("konqueror")) - # Gnome's Galeon and Epiphany - for browser in ("galeon", "epiphany"): - if shutil.which(browser): - register(browser, None, Galeon(browser)) + # Gnome's Epiphany + if shutil.which("epiphany"): + register(browser, None, Epiphany("epiphany")) # Skipstone, another Gtk/Mozilla based browser if shutil.which("skipstone"): @@ -514,13 +458,6 @@ def register_X_browsers(): if shutil.which("opera"): register("opera", None, Opera("opera")) - # Next, Mosaic -- old but still in use. - if shutil.which("mosaic"): - register("mosaic", None, BackgroundBrowser("mosaic")) - - # Grail, the Python browser. Does anybody still use it? - if shutil.which("grail"): - register("grail", Grail, None) def register_standard_browsers(): global _tryorder @@ -549,7 +486,7 @@ def register_standard_browsers(): # location in 32-bit Windows edge32 = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"), "Microsoft\\Edge\\Application\\msedge.exe") - for browser in ("firefox", "firebird", "seamonkey", "mozilla", + for browser in ("firefox", "seamonkey", "mozilla", "chrome", "opera", edge64, edge32): if shutil.which(browser): register(browser, None, BackgroundBrowser(browser)) @@ -570,14 +507,15 @@ def register_standard_browsers(): # Also try console browsers if os.environ.get("TERM"): + # Common symbolic link for the default text-based browser if shutil.which("www-browser"): register("www-browser", None, GenericBrowser("www-browser")) - # The Links/elinks browsers + # The Links/elinks browsers if shutil.which("links"): register("links", None, GenericBrowser("links")) if shutil.which("elinks"): register("elinks", None, Elinks("elinks")) - # The Lynx browser , + # The Lynx browser , if shutil.which("lynx"): register("lynx", None, GenericBrowser("lynx")) # The w3m browser From cf7209d3efb0139291488f5faa2f15a5859eb82d Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 15:17:08 +0000 Subject: [PATCH 2/9] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst diff --git a/Misc/NEWS.d/next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst b/Misc/NEWS.d/next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst new file mode 100644 index 00000000000000..cccba296418922 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst @@ -0,0 +1 @@ +Remove support for obsolete browsers from :mod:`webbrowser` From aee1f917bf9a172492ccaf05789a0e7bbba274ed Mon Sep 17 00:00:00 2001 From: james Date: Wed, 22 Mar 2023 21:28:55 +1100 Subject: [PATCH 3/9] Small comment fix --- Lib/webbrowser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 0191533a401838..fa1c53b1aadce6 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -425,7 +425,7 @@ def register_X_browsers(): if "KDE_FULL_SESSION" in os.environ and shutil.which("kfmclient"): register("kfmclient", Konqueror, Konqueror("kfmclient")) - # Common symbolic link for the default text-based browser + # Common symbolic link for the default X11 browser if shutil.which("x-www-browser"): register("x-www-browser", None, BackgroundBrowser("x-www-browser")) From ee7c8647d59058271922b45d0a1d428fe46cba27 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 22 Mar 2023 21:49:13 +1100 Subject: [PATCH 4/9] Remove Skipstone --- Doc/library/webbrowser.rst | 2 -- Lib/webbrowser.py | 4 ---- 2 files changed, 6 deletions(-) diff --git a/Doc/library/webbrowser.rst b/Doc/library/webbrowser.rst index 65b521a4b7fb66..b6a51e51e64385 100644 --- a/Doc/library/webbrowser.rst +++ b/Doc/library/webbrowser.rst @@ -117,8 +117,6 @@ for the controller classes, all defined in this module. +------------------------+-----------------------------------------+-------+ | ``'epiphany'`` | :class:`Epiphany('epiphany')` | | +------------------------+-----------------------------------------+-------+ -| ``'skipstone'`` | :class:`BackgroundBrowser('skipstone')` | | -+------------------------+-----------------------------------------+-------+ | ``'kfmclient'`` | :class:`Konqueror()` | \(1) | +------------------------+-----------------------------------------+-------+ | ``'konqueror'`` | :class:`Konqueror()` | \(1) | diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index fa1c53b1aadce6..f8b27f47624a01 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -445,10 +445,6 @@ def register_X_browsers(): if shutil.which("epiphany"): register(browser, None, Epiphany("epiphany")) - # Skipstone, another Gtk/Mozilla based browser - if shutil.which("skipstone"): - register("skipstone", None, BackgroundBrowser("skipstone")) - # Google Chrome/Chromium browsers for browser in ("google-chrome", "chrome", "chromium", "chromium-browser"): if shutil.which(browser): From 798f4397c6b305b6a6b24aef48c45bed5a6d9a45 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 27 Mar 2023 10:25:52 +1100 Subject: [PATCH 5/9] Fix whitespace test failure and spacing between classes --- Lib/webbrowser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 84fba3a914fcb6..fd43d4930a0dd2 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -390,6 +390,7 @@ def open(self, url, new=0, autoraise=True): else: return (p.poll() is None) + def open(self, url, new=0, autoraise=True): sys.audit("webbrowser.open", url) if new: @@ -661,7 +662,7 @@ def main(): for o, a in opts: if o == '-n': new_win = 1 elif o == '-t': new_win = 2 - elif o == '-h' or o == '--help': + elif o == '-h' or o == '--help': print(usage, file=sys.stderr) sys.exit() if len(args) != 1: From 21bcde7d1257d31f3a09b967c58184fe825a4cf5 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 27 Mar 2023 11:19:02 +1100 Subject: [PATCH 6/9] Name the removed browsers in News and Module docs --- Doc/library/webbrowser.rst | 5 +++++ .../Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Doc/library/webbrowser.rst b/Doc/library/webbrowser.rst index b6a51e51e64385..61db8042093627 100644 --- a/Doc/library/webbrowser.rst +++ b/Doc/library/webbrowser.rst @@ -166,6 +166,11 @@ Notes: .. versionadded:: 3.3 Support for Chrome/Chromium has been added. +.. versionchanged:: 3.12 + Support for several obsolete browsers has been removed. + Removed browsers include Grail, Mosaic, Netscape, Galeon, + Skipstone, Iceape, and Firefox versions 35 and below. + .. deprecated-removed:: 3.11 3.13 :class:`MacOSX` is deprecated, use :class:`MacOSXOSAScript` instead. diff --git a/Misc/NEWS.d/next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst b/Misc/NEWS.d/next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst index cccba296418922..3ef0e74d21ca00 100644 --- a/Misc/NEWS.d/next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst +++ b/Misc/NEWS.d/next/Library/2023-03-21-15-17-07.gh-issue-102871.U9mchn.rst @@ -1 +1,3 @@ -Remove support for obsolete browsers from :mod:`webbrowser` +Remove support for obsolete browsers from :mod:`webbrowser`. +Removed browsers include Grail, Mosaic, Netscape, Galeon, Skipstone, +Iceape, Firebird, and Firefox versions 35 and below. From 90fa6d2e0b2012aa8a50673df110f6fb5d12c204 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 27 Mar 2023 20:18:25 +1100 Subject: [PATCH 7/9] Register epiphany by name to match surrounding code --- Lib/webbrowser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index fd43d4930a0dd2..6befc03ad54d81 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -444,7 +444,7 @@ def register_X_browsers(): # Gnome's Epiphany if shutil.which("epiphany"): - register(browser, None, Epiphany("epiphany")) + register("epiphany", None, Epiphany("epiphany")) # Google Chrome/Chromium browsers for browser in ("google-chrome", "chrome", "chromium", "chromium-browser"): From bdab9685d3134849592954f6f1149406f316a22d Mon Sep 17 00:00:00 2001 From: James De Bias <81095953+DBJim@users.noreply.github.com> Date: Tue, 28 Mar 2023 08:05:31 +1100 Subject: [PATCH 8/9] Fix typo Co-authored-by: Serhiy Storchaka --- Lib/webbrowser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 6befc03ad54d81..d98c5997d2f44f 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -507,7 +507,7 @@ def register_standard_browsers(): # Common symbolic link for the default text-based browser if shutil.which("www-browser"): register("www-browser", None, GenericBrowser("www-browser")) - # The Links/elinks browsers + # The Links/elinks browsers if shutil.which("links"): register("links", None, GenericBrowser("links")) if shutil.which("elinks"): From 7b1d4f947c6c673b4b09038c9d0271aa3fadc8c9 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 28 Mar 2023 10:05:42 +1100 Subject: [PATCH 9/9] Add 'whatsnew' entry --- Doc/whatsnew/3.12.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index e5bcfdecd9a487..411a48a033b37f 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -777,6 +777,10 @@ Removed *context* parameter instead. (Contributed by Victor Stinner in :gh:`94172`.) +* Remove support for obsolete browsers from :mod:`webbrowser`. + Removed browsers include: Grail, Mosaic, Netscape, Galeon, Skipstone, + Iceape, Firebird, and Firefox versions 35 and below (:gh:`102871`). + Porting to Python 3.12 ======================