gh-102871: Remove obsolete browsers from webbrowser (#102872)

This commit is contained in:
James De Bias 2023-04-01 02:02:47 +11:00 committed by GitHub
parent 048d6243d4
commit b0422e140d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 117 deletions

View file

@ -115,13 +115,7 @@ for the controller classes, all defined in this module.
+------------------------+-----------------------------------------+-------+ +------------------------+-----------------------------------------+-------+
| ``'firefox'`` | :class:`Mozilla('mozilla')` | | | ``'firefox'`` | :class:`Mozilla('mozilla')` | |
+------------------------+-----------------------------------------+-------+ +------------------------+-----------------------------------------+-------+
| ``'netscape'`` | :class:`Mozilla('netscape')` | | | ``'epiphany'`` | :class:`Epiphany('epiphany')` | |
+------------------------+-----------------------------------------+-------+
| ``'galeon'`` | :class:`Galeon('galeon')` | |
+------------------------+-----------------------------------------+-------+
| ``'epiphany'`` | :class:`Galeon('epiphany')` | |
+------------------------+-----------------------------------------+-------+
| ``'skipstone'`` | :class:`BackgroundBrowser('skipstone')` | |
+------------------------+-----------------------------------------+-------+ +------------------------+-----------------------------------------+-------+
| ``'kfmclient'`` | :class:`Konqueror()` | \(1) | | ``'kfmclient'`` | :class:`Konqueror()` | \(1) |
+------------------------+-----------------------------------------+-------+ +------------------------+-----------------------------------------+-------+
@ -129,12 +123,8 @@ for the controller classes, all defined in this module.
+------------------------+-----------------------------------------+-------+ +------------------------+-----------------------------------------+-------+
| ``'kfm'`` | :class:`Konqueror()` | \(1) | | ``'kfm'`` | :class:`Konqueror()` | \(1) |
+------------------------+-----------------------------------------+-------+ +------------------------+-----------------------------------------+-------+
| ``'mosaic'`` | :class:`BackgroundBrowser('mosaic')` | |
+------------------------+-----------------------------------------+-------+
| ``'opera'`` | :class:`Opera()` | | | ``'opera'`` | :class:`Opera()` | |
+------------------------+-----------------------------------------+-------+ +------------------------+-----------------------------------------+-------+
| ``'grail'`` | :class:`Grail()` | |
+------------------------+-----------------------------------------+-------+
| ``'links'`` | :class:`GenericBrowser('links')` | | | ``'links'`` | :class:`GenericBrowser('links')` | |
+------------------------+-----------------------------------------+-------+ +------------------------+-----------------------------------------+-------+
| ``'elinks'`` | :class:`Elinks('elinks')` | | | ``'elinks'`` | :class:`Elinks('elinks')` | |
@ -176,6 +166,11 @@ Notes:
.. versionadded:: 3.3 .. versionadded:: 3.3
Support for Chrome/Chromium has been added. 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 .. deprecated-removed:: 3.11 3.13
:class:`MacOSX` is deprecated, use :class:`MacOSXOSAScript` instead. :class:`MacOSX` is deprecated, use :class:`MacOSXOSAScript` instead.

View file

@ -777,6 +777,10 @@ Removed
*context* parameter instead. *context* parameter instead.
(Contributed by Victor Stinner in :gh:`94172`.) (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 Porting to Python 3.12
====================== ======================

View file

@ -11,7 +11,7 @@ from test.support import os_helper
if not support.has_subprocess_support: if not support.has_subprocess_support:
raise unittest.SkipTest("test webserver requires subprocess") raise unittest.SkipTest("test webserver requires subprocess")
URL = 'http://www.example.com' URL = 'https://www.example.com'
CMD_NAME = 'test' CMD_NAME = 'test'
@ -120,34 +120,9 @@ class MozillaCommandTest(CommandTestMixin, unittest.TestCase):
arguments=['-new-tab', URL]) arguments=['-new-tab', URL])
class NetscapeCommandTest(CommandTestMixin, unittest.TestCase): class EpiphanyCommandTest(CommandTestMixin, unittest.TestCase):
browser_class = webbrowser.Netscape browser_class = webbrowser.Epiphany
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
def test_open(self): def test_open(self):
self._test('open', self._test('open',

View file

@ -292,19 +292,8 @@ class Mozilla(UnixBrowser):
background = True background = True
class Netscape(UnixBrowser): class Epiphany(UnixBrowser):
"""Launcher class for Netscape browser.""" """Launcher class for Epiphany 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."""
raise_opts = ["-noraise", ""] raise_opts = ["-noraise", ""]
remote_args = ['%action', '%s'] remote_args = ['%action', '%s']
@ -402,44 +391,6 @@ class Konqueror(BaseBrowser):
return (p.poll() is None) 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): def open(self, url, new=0, autoraise=True):
sys.audit("webbrowser.open", url) sys.audit("webbrowser.open", url)
if new: if new:
@ -475,35 +426,25 @@ def register_X_browsers():
if "KDE_FULL_SESSION" in os.environ and shutil.which("kfmclient"): if "KDE_FULL_SESSION" in os.environ and shutil.which("kfmclient"):
register("kfmclient", Konqueror, Konqueror("kfmclient")) register("kfmclient", Konqueror, Konqueror("kfmclient"))
# Common symbolic link for the default X11 browser
if shutil.which("x-www-browser"): if shutil.which("x-www-browser"):
register("x-www-browser", None, BackgroundBrowser("x-www-browser")) register("x-www-browser", None, BackgroundBrowser("x-www-browser"))
# The Mozilla browsers # The Mozilla browsers
for browser in ("firefox", "iceweasel", "iceape", "seamonkey"): for browser in ("firefox", "iceweasel", "seamonkey", "mozilla-firefox",
"mozilla"):
if shutil.which(browser): if shutil.which(browser):
register(browser, None, Mozilla(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. # Konqueror/kfm, the KDE browser.
if shutil.which("kfm"): if shutil.which("kfm"):
register("kfm", Konqueror, Konqueror("kfm")) register("kfm", Konqueror, Konqueror("kfm"))
elif shutil.which("konqueror"): elif shutil.which("konqueror"):
register("konqueror", Konqueror, Konqueror("konqueror")) register("konqueror", Konqueror, Konqueror("konqueror"))
# Gnome's Galeon and Epiphany # Gnome's Epiphany
for browser in ("galeon", "epiphany"): if shutil.which("epiphany"):
if shutil.which(browser): register("epiphany", None, Epiphany("epiphany"))
register(browser, None, Galeon(browser))
# Skipstone, another Gtk/Mozilla based browser
if shutil.which("skipstone"):
register("skipstone", None, BackgroundBrowser("skipstone"))
# Google Chrome/Chromium browsers # Google Chrome/Chromium browsers
for browser in ("google-chrome", "chrome", "chromium", "chromium-browser"): for browser in ("google-chrome", "chrome", "chromium", "chromium-browser"):
@ -514,13 +455,6 @@ def register_X_browsers():
if shutil.which("opera"): if shutil.which("opera"):
register("opera", None, Opera("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(): def register_standard_browsers():
global _tryorder global _tryorder
@ -549,7 +483,7 @@ def register_standard_browsers():
# location in 32-bit Windows # location in 32-bit Windows
edge32 = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"), edge32 = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"),
"Microsoft\\Edge\\Application\\msedge.exe") "Microsoft\\Edge\\Application\\msedge.exe")
for browser in ("firefox", "firebird", "seamonkey", "mozilla", for browser in ("firefox", "seamonkey", "mozilla", "chrome",
"opera", edge64, edge32): "opera", edge64, edge32):
if shutil.which(browser): if shutil.which(browser):
register(browser, None, BackgroundBrowser(browser)) register(browser, None, BackgroundBrowser(browser))
@ -570,14 +504,15 @@ def register_standard_browsers():
# Also try console browsers # Also try console browsers
if os.environ.get("TERM"): if os.environ.get("TERM"):
# Common symbolic link for the default text-based browser
if shutil.which("www-browser"): if shutil.which("www-browser"):
register("www-browser", None, GenericBrowser("www-browser")) register("www-browser", None, GenericBrowser("www-browser"))
# The Links/elinks browsers <http://artax.karlin.mff.cuni.cz/~mikulas/links/> # The Links/elinks browsers <http://links.twibright.com/>
if shutil.which("links"): if shutil.which("links"):
register("links", None, GenericBrowser("links")) register("links", None, GenericBrowser("links"))
if shutil.which("elinks"): if shutil.which("elinks"):
register("elinks", None, Elinks("elinks")) register("elinks", None, Elinks("elinks"))
# The Lynx browser <http://lynx.isc.org/>, <http://lynx.browser.org/> # The Lynx browser <https://lynx.invisible-island.net/>, <http://lynx.browser.org/>
if shutil.which("lynx"): if shutil.which("lynx"):
register("lynx", None, GenericBrowser("lynx")) register("lynx", None, GenericBrowser("lynx"))
# The w3m browser <http://w3m.sourceforge.net/> # The w3m browser <http://w3m.sourceforge.net/>
@ -727,7 +662,7 @@ def main():
for o, a in opts: for o, a in opts:
if o == '-n': new_win = 1 if o == '-n': new_win = 1
elif o == '-t': new_win = 2 elif o == '-t': new_win = 2
elif o == '-h' or o == '--help': elif o == '-h' or o == '--help':
print(usage, file=sys.stderr) print(usage, file=sys.stderr)
sys.exit() sys.exit()
if len(args) != 1: if len(args) != 1:

View file

@ -0,0 +1,3 @@
Remove support for obsolete browsers from :mod:`webbrowser`.
Removed browsers include Grail, Mosaic, Netscape, Galeon, Skipstone,
Iceape, Firebird, and Firefox versions 35 and below.