Skip to content

Commit b0422e1

Browse files
authored
gh-102871: Remove obsolete browsers from webbrowser (#102872)
1 parent 048d624 commit b0422e1

File tree

5 files changed

+29
-117
lines changed

5 files changed

+29
-117
lines changed

Doc/library/webbrowser.rst

+6-11
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,16 @@ for the controller classes, all defined in this module.
115115
+------------------------+-----------------------------------------+-------+
116116
| ``'firefox'`` | :class:`Mozilla('mozilla')` | |
117117
+------------------------+-----------------------------------------+-------+
118-
| ``'netscape'`` | :class:`Mozilla('netscape')` | |
119-
+------------------------+-----------------------------------------+-------+
120-
| ``'galeon'`` | :class:`Galeon('galeon')` | |
121-
+------------------------+-----------------------------------------+-------+
122-
| ``'epiphany'`` | :class:`Galeon('epiphany')` | |
123-
+------------------------+-----------------------------------------+-------+
124-
| ``'skipstone'`` | :class:`BackgroundBrowser('skipstone')` | |
118+
| ``'epiphany'`` | :class:`Epiphany('epiphany')` | |
125119
+------------------------+-----------------------------------------+-------+
126120
| ``'kfmclient'`` | :class:`Konqueror()` | \(1) |
127121
+------------------------+-----------------------------------------+-------+
128122
| ``'konqueror'`` | :class:`Konqueror()` | \(1) |
129123
+------------------------+-----------------------------------------+-------+
130124
| ``'kfm'`` | :class:`Konqueror()` | \(1) |
131125
+------------------------+-----------------------------------------+-------+
132-
| ``'mosaic'`` | :class:`BackgroundBrowser('mosaic')` | |
133-
+------------------------+-----------------------------------------+-------+
134126
| ``'opera'`` | :class:`Opera()` | |
135127
+------------------------+-----------------------------------------+-------+
136-
| ``'grail'`` | :class:`Grail()` | |
137-
+------------------------+-----------------------------------------+-------+
138128
| ``'links'`` | :class:`GenericBrowser('links')` | |
139129
+------------------------+-----------------------------------------+-------+
140130
| ``'elinks'`` | :class:`Elinks('elinks')` | |
@@ -176,6 +166,11 @@ Notes:
176166
.. versionadded:: 3.3
177167
Support for Chrome/Chromium has been added.
178168

169+
.. versionchanged:: 3.12
170+
Support for several obsolete browsers has been removed.
171+
Removed browsers include Grail, Mosaic, Netscape, Galeon,
172+
Skipstone, Iceape, and Firefox versions 35 and below.
173+
179174
.. deprecated-removed:: 3.11 3.13
180175
:class:`MacOSX` is deprecated, use :class:`MacOSXOSAScript` instead.
181176

Doc/whatsnew/3.12.rst

+4
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ Removed
777777
*context* parameter instead.
778778
(Contributed by Victor Stinner in :gh:`94172`.)
779779

780+
* Remove support for obsolete browsers from :mod:`webbrowser`.
781+
Removed browsers include: Grail, Mosaic, Netscape, Galeon, Skipstone,
782+
Iceape, Firebird, and Firefox versions 35 and below (:gh:`102871`).
783+
780784

781785
Porting to Python 3.12
782786
======================

Lib/test/test_webbrowser.py

+3-28
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
if not support.has_subprocess_support:
1212
raise unittest.SkipTest("test webserver requires subprocess")
1313

14-
URL = 'http://www.example.com'
14+
URL = 'https://www.example.com'
1515
CMD_NAME = 'test'
1616

1717

@@ -120,34 +120,9 @@ def test_open_new_tab(self):
120120
arguments=['-new-tab', URL])
121121

122122

123-
class NetscapeCommandTest(CommandTestMixin, unittest.TestCase):
123+
class EpiphanyCommandTest(CommandTestMixin, unittest.TestCase):
124124

125-
browser_class = webbrowser.Netscape
126-
127-
def test_open(self):
128-
self._test('open',
129-
options=['-raise', '-remote'],
130-
arguments=['openURL({})'.format(URL)])
131-
132-
def test_open_with_autoraise_false(self):
133-
self._test('open', kw=dict(autoraise=False),
134-
options=['-noraise', '-remote'],
135-
arguments=['openURL({})'.format(URL)])
136-
137-
def test_open_new(self):
138-
self._test('open_new',
139-
options=['-raise', '-remote'],
140-
arguments=['openURL({},new-window)'.format(URL)])
141-
142-
def test_open_new_tab(self):
143-
self._test('open_new_tab',
144-
options=['-raise', '-remote'],
145-
arguments=['openURL({},new-tab)'.format(URL)])
146-
147-
148-
class GaleonCommandTest(CommandTestMixin, unittest.TestCase):
149-
150-
browser_class = webbrowser.Galeon
125+
browser_class = webbrowser.Epiphany
151126

152127
def test_open(self):
153128
self._test('open',

Lib/webbrowser.py

+13-78
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,8 @@ class Mozilla(UnixBrowser):
292292
background = True
293293

294294

295-
class Netscape(UnixBrowser):
296-
"""Launcher class for Netscape browser."""
297-
298-
raise_opts = ["-noraise", "-raise"]
299-
remote_args = ['-remote', 'openURL(%s%action)']
300-
remote_action = ""
301-
remote_action_newwin = ",new-window"
302-
remote_action_newtab = ",new-tab"
303-
background = True
304-
305-
306-
class Galeon(UnixBrowser):
307-
"""Launcher class for Galeon/Epiphany browsers."""
295+
class Epiphany(UnixBrowser):
296+
"""Launcher class for Epiphany browser."""
308297

309298
raise_opts = ["-noraise", ""]
310299
remote_args = ['%action', '%s']
@@ -402,44 +391,6 @@ def open(self, url, new=0, autoraise=True):
402391
return (p.poll() is None)
403392

404393

405-
class Grail(BaseBrowser):
406-
# There should be a way to maintain a connection to Grail, but the
407-
# Grail remote control protocol doesn't really allow that at this
408-
# point. It probably never will!
409-
def _find_grail_rc(self):
410-
import glob
411-
import pwd
412-
import socket
413-
import tempfile
414-
tempdir = os.path.join(tempfile.gettempdir(),
415-
".grail-unix")
416-
user = pwd.getpwuid(os.getuid())[0]
417-
filename = os.path.join(glob.escape(tempdir), glob.escape(user) + "-*")
418-
maybes = glob.glob(filename)
419-
if not maybes:
420-
return None
421-
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
422-
for fn in maybes:
423-
# need to PING each one until we find one that's live
424-
try:
425-
s.connect(fn)
426-
except OSError:
427-
# no good; attempt to clean it out, but don't fail:
428-
try:
429-
os.unlink(fn)
430-
except OSError:
431-
pass
432-
else:
433-
return s
434-
435-
def _remote(self, action):
436-
s = self._find_grail_rc()
437-
if not s:
438-
return 0
439-
s.send(action)
440-
s.close()
441-
return 1
442-
443394
def open(self, url, new=0, autoraise=True):
444395
sys.audit("webbrowser.open", url)
445396
if new:
@@ -475,35 +426,25 @@ def register_X_browsers():
475426
if "KDE_FULL_SESSION" in os.environ and shutil.which("kfmclient"):
476427
register("kfmclient", Konqueror, Konqueror("kfmclient"))
477428

429+
# Common symbolic link for the default X11 browser
478430
if shutil.which("x-www-browser"):
479431
register("x-www-browser", None, BackgroundBrowser("x-www-browser"))
480432

481433
# The Mozilla browsers
482-
for browser in ("firefox", "iceweasel", "iceape", "seamonkey"):
434+
for browser in ("firefox", "iceweasel", "seamonkey", "mozilla-firefox",
435+
"mozilla"):
483436
if shutil.which(browser):
484437
register(browser, None, Mozilla(browser))
485438

486-
# The Netscape and old Mozilla browsers
487-
for browser in ("mozilla-firefox",
488-
"mozilla-firebird", "firebird",
489-
"mozilla", "netscape"):
490-
if shutil.which(browser):
491-
register(browser, None, Netscape(browser))
492-
493439
# Konqueror/kfm, the KDE browser.
494440
if shutil.which("kfm"):
495441
register("kfm", Konqueror, Konqueror("kfm"))
496442
elif shutil.which("konqueror"):
497443
register("konqueror", Konqueror, Konqueror("konqueror"))
498444

499-
# Gnome's Galeon and Epiphany
500-
for browser in ("galeon", "epiphany"):
501-
if shutil.which(browser):
502-
register(browser, None, Galeon(browser))
503-
504-
# Skipstone, another Gtk/Mozilla based browser
505-
if shutil.which("skipstone"):
506-
register("skipstone", None, BackgroundBrowser("skipstone"))
445+
# Gnome's Epiphany
446+
if shutil.which("epiphany"):
447+
register("epiphany", None, Epiphany("epiphany"))
507448

508449
# Google Chrome/Chromium browsers
509450
for browser in ("google-chrome", "chrome", "chromium", "chromium-browser"):
@@ -514,13 +455,6 @@ def register_X_browsers():
514455
if shutil.which("opera"):
515456
register("opera", None, Opera("opera"))
516457

517-
# Next, Mosaic -- old but still in use.
518-
if shutil.which("mosaic"):
519-
register("mosaic", None, BackgroundBrowser("mosaic"))
520-
521-
# Grail, the Python browser. Does anybody still use it?
522-
if shutil.which("grail"):
523-
register("grail", Grail, None)
524458

525459
def register_standard_browsers():
526460
global _tryorder
@@ -549,7 +483,7 @@ def register_standard_browsers():
549483
# location in 32-bit Windows
550484
edge32 = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"),
551485
"Microsoft\\Edge\\Application\\msedge.exe")
552-
for browser in ("firefox", "firebird", "seamonkey", "mozilla",
486+
for browser in ("firefox", "seamonkey", "mozilla", "chrome",
553487
"opera", edge64, edge32):
554488
if shutil.which(browser):
555489
register(browser, None, BackgroundBrowser(browser))
@@ -570,14 +504,15 @@ def register_standard_browsers():
570504

571505
# Also try console browsers
572506
if os.environ.get("TERM"):
507+
# Common symbolic link for the default text-based browser
573508
if shutil.which("www-browser"):
574509
register("www-browser", None, GenericBrowser("www-browser"))
575-
# The Links/elinks browsers <http://artax.karlin.mff.cuni.cz/~mikulas/links/>
510+
# The Links/elinks browsers <http://links.twibright.com/>
576511
if shutil.which("links"):
577512
register("links", None, GenericBrowser("links"))
578513
if shutil.which("elinks"):
579514
register("elinks", None, Elinks("elinks"))
580-
# The Lynx browser <http://lynx.isc.org/>, <http://lynx.browser.org/>
515+
# The Lynx browser <https://lynx.invisible-island.net/>, <http://lynx.browser.org/>
581516
if shutil.which("lynx"):
582517
register("lynx", None, GenericBrowser("lynx"))
583518
# The w3m browser <http://w3m.sourceforge.net/>
@@ -727,7 +662,7 @@ def main():
727662
for o, a in opts:
728663
if o == '-n': new_win = 1
729664
elif o == '-t': new_win = 2
730-
elif o == '-h' or o == '--help':
665+
elif o == '-h' or o == '--help':
731666
print(usage, file=sys.stderr)
732667
sys.exit()
733668
if len(args) != 1:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove support for obsolete browsers from :mod:`webbrowser`.
2+
Removed browsers include Grail, Mosaic, Netscape, Galeon, Skipstone,
3+
Iceape, Firebird, and Firefox versions 35 and below.

0 commit comments

Comments
 (0)