mirror of https://github.com/python/cpython
gh-104804: Remove webbrowser.MacOSX class, deprecated in Python 3.11 (#104816)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
afa759fb80
commit
5ab4bc05c4
|
@ -20,7 +20,7 @@ will be used if graphical browsers are not available or an X11 display isn't
|
|||
available. If text-mode browsers are used, the calling process will block until
|
||||
the user exits the browser.
|
||||
|
||||
If the environment variable :envvar:`BROWSER` exists, it is interpreted as the
|
||||
If the environment variable :envvar:`!BROWSER` exists, it is interpreted as the
|
||||
:data:`os.pathsep`-separated list of browsers to try ahead of the platform
|
||||
defaults. When the value of a list part contains the string ``%s``, then it is
|
||||
interpreted as a literal browser command line to be used with the argument URL
|
||||
|
@ -97,7 +97,7 @@ The following functions are defined:
|
|||
|
||||
Setting *preferred* to ``True`` makes this browser a preferred result for
|
||||
a :func:`get` call with no argument. Otherwise, this entry point is only
|
||||
useful if you plan to either set the :envvar:`BROWSER` variable or call
|
||||
useful if you plan to either set the :envvar:`!BROWSER` variable or call
|
||||
:func:`get` with a nonempty argument matching the name of a handler you
|
||||
declare.
|
||||
|
||||
|
@ -111,41 +111,41 @@ for the controller classes, all defined in this module.
|
|||
+------------------------+-----------------------------------------+-------+
|
||||
| Type Name | Class Name | Notes |
|
||||
+========================+=========================================+=======+
|
||||
| ``'mozilla'`` | :class:`Mozilla('mozilla')` | |
|
||||
| ``'mozilla'`` | ``Mozilla('mozilla')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'firefox'`` | :class:`Mozilla('mozilla')` | |
|
||||
| ``'firefox'`` | ``Mozilla('mozilla')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'epiphany'`` | :class:`Epiphany('epiphany')` | |
|
||||
| ``'epiphany'`` | ``Epiphany('epiphany')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'kfmclient'`` | :class:`Konqueror()` | \(1) |
|
||||
| ``'kfmclient'`` | ``Konqueror()`` | \(1) |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'konqueror'`` | :class:`Konqueror()` | \(1) |
|
||||
| ``'konqueror'`` | ``Konqueror()`` | \(1) |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'kfm'`` | :class:`Konqueror()` | \(1) |
|
||||
| ``'kfm'`` | ``Konqueror()`` | \(1) |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'opera'`` | :class:`Opera()` | |
|
||||
| ``'opera'`` | ``Opera()`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'links'`` | :class:`GenericBrowser('links')` | |
|
||||
| ``'links'`` | ``GenericBrowser('links')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'elinks'`` | :class:`Elinks('elinks')` | |
|
||||
| ``'elinks'`` | ``Elinks('elinks')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'lynx'`` | :class:`GenericBrowser('lynx')` | |
|
||||
| ``'lynx'`` | ``GenericBrowser('lynx')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'w3m'`` | :class:`GenericBrowser('w3m')` | |
|
||||
| ``'w3m'`` | ``GenericBrowser('w3m')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'windows-default'`` | :class:`WindowsDefault` | \(2) |
|
||||
| ``'windows-default'`` | ``WindowsDefault`` | \(2) |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'macosx'`` | :class:`MacOSXOSAScript('default')` | \(3) |
|
||||
| ``'macosx'`` | ``MacOSXOSAScript('default')`` | \(3) |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'safari'`` | :class:`MacOSXOSAScript('safari')` | \(3) |
|
||||
| ``'safari'`` | ``MacOSXOSAScript('safari')`` | \(3) |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'google-chrome'`` | :class:`Chrome('google-chrome')` | |
|
||||
| ``'google-chrome'`` | ``Chrome('google-chrome')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'chrome'`` | :class:`Chrome('chrome')` | |
|
||||
| ``'chrome'`` | ``Chrome('chrome')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'chromium'`` | :class:`Chromium('chromium')` | |
|
||||
| ``'chromium'`` | ``Chromium('chromium')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
| ``'chromium-browser'`` | :class:`Chromium('chromium-browser')` | |
|
||||
| ``'chromium-browser'`` | ``Chromium('chromium-browser')`` | |
|
||||
+------------------------+-----------------------------------------+-------+
|
||||
|
||||
Notes:
|
||||
|
@ -153,7 +153,7 @@ Notes:
|
|||
(1)
|
||||
"Konqueror" is the file manager for the KDE desktop environment for Unix, and
|
||||
only makes sense to use if KDE is running. Some way of reliably detecting KDE
|
||||
would be nice; the :envvar:`KDEDIR` variable is not sufficient. Note also that
|
||||
would be nice; the :envvar:`!KDEDIR` variable is not sufficient. Note also that
|
||||
the name "kfm" is used even when using the :program:`konqueror` command with KDE
|
||||
2 --- the implementation selects the best strategy for running Konqueror.
|
||||
|
||||
|
@ -163,6 +163,11 @@ Notes:
|
|||
(3)
|
||||
Only on macOS platform.
|
||||
|
||||
.. versionadded:: 3.2
|
||||
A new :class:`!MacOSXOSAScript` class has been added
|
||||
and is used on Mac instead of the previous :class:`!MacOSX` class.
|
||||
This adds support for opening browsers not currently set as the OS default.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
Support for Chrome/Chromium has been added.
|
||||
|
||||
|
@ -171,9 +176,6 @@ Notes:
|
|||
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.
|
||||
|
||||
Here are some simple examples::
|
||||
|
||||
url = 'https://docs.python.org/'
|
||||
|
@ -222,4 +224,4 @@ module-level convenience functions:
|
|||
.. rubric:: Footnotes
|
||||
|
||||
.. [1] Executables named here without a full path will be searched in the
|
||||
directories given in the :envvar:`PATH` environment variable.
|
||||
directories given in the :envvar:`!PATH` environment variable.
|
||||
|
|
|
@ -229,7 +229,6 @@ Doc/library/urllib.request.rst
|
|||
Doc/library/uuid.rst
|
||||
Doc/library/wave.rst
|
||||
Doc/library/weakref.rst
|
||||
Doc/library/webbrowser.rst
|
||||
Doc/library/winreg.rst
|
||||
Doc/library/winsound.rst
|
||||
Doc/library/wsgiref.rst
|
||||
|
|
|
@ -115,6 +115,11 @@ Removed
|
|||
are now removed. The items in those namespaces can be imported directly
|
||||
from :mod:`typing`. (Contributed by Sebastian Rittau in :gh:`92871`.)
|
||||
|
||||
* Remove the untested and undocumented :mod:`webbrowser` :class:`!MacOSX` class,
|
||||
deprecated in Python 3.11.
|
||||
Use the :class:`!MacOSXOSAScript` class (introduced in Python 3.2) instead.
|
||||
(Contributed by Hugo van Kemenade in :gh:`104804`.)
|
||||
|
||||
* Remove support for using :class:`pathlib.Path` objects as context managers.
|
||||
This functionality was deprecated and made a no-op in Python 3.9.
|
||||
|
||||
|
|
|
@ -570,60 +570,10 @@ if sys.platform[:3] == "win":
|
|||
return True
|
||||
|
||||
#
|
||||
# Platform support for MacOS
|
||||
# Platform support for macOS
|
||||
#
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
# Adapted from patch submitted to SourceForge by Steven J. Burr
|
||||
class MacOSX(BaseBrowser):
|
||||
"""Launcher class for Aqua browsers on Mac OS X
|
||||
|
||||
Optionally specify a browser name on instantiation. Note that this
|
||||
will not work for Aqua browsers if the user has moved the application
|
||||
package after installation.
|
||||
|
||||
If no browser is specified, the default browser, as specified in the
|
||||
Internet System Preferences panel, will be used.
|
||||
"""
|
||||
def __init__(self, name):
|
||||
warnings.warn(f'{self.__class__.__name__} is deprecated in 3.11'
|
||||
' use MacOSXOSAScript instead.', DeprecationWarning, stacklevel=2)
|
||||
self.name = name
|
||||
|
||||
def open(self, url, new=0, autoraise=True):
|
||||
sys.audit("webbrowser.open", url)
|
||||
assert "'" not in url
|
||||
# hack for local urls
|
||||
if not ':' in url:
|
||||
url = 'file:'+url
|
||||
|
||||
# new must be 0 or 1
|
||||
new = int(bool(new))
|
||||
if self.name == "default":
|
||||
# User called open, open_new or get without a browser parameter
|
||||
script = 'open location "%s"' % url.replace('"', '%22') # opens in default browser
|
||||
else:
|
||||
# User called get and chose a browser
|
||||
if self.name == "OmniWeb":
|
||||
toWindow = ""
|
||||
else:
|
||||
# Include toWindow parameter of OpenURL command for browsers
|
||||
# that support it. 0 == new window; -1 == existing
|
||||
toWindow = "toWindow %d" % (new - 1)
|
||||
cmd = 'OpenURL "%s"' % url.replace('"', '%22')
|
||||
script = '''tell application "%s"
|
||||
activate
|
||||
%s %s
|
||||
end tell''' % (self.name, cmd, toWindow)
|
||||
# Open pipe to AppleScript through osascript command
|
||||
osapipe = os.popen("osascript", "w")
|
||||
if osapipe is None:
|
||||
return False
|
||||
# Write script to osascript's stdin
|
||||
osapipe.write(script)
|
||||
rc = osapipe.close()
|
||||
return not rc
|
||||
|
||||
class MacOSXOSAScript(BaseBrowser):
|
||||
def __init__(self, name='default'):
|
||||
super().__init__(name)
|
||||
|
|
|
@ -1966,8 +1966,8 @@ A new function ``operator.call`` has been added, such that
|
|||
.. nonce: ofe3ms
|
||||
.. section: Library
|
||||
|
||||
:class:`webbrowser.MacOSX` is deprecated and will be removed in Python 3.13.
|
||||
It is untested and undocumented and also not used by webbrowser itself.
|
||||
:class:`!webbrowser.MacOSX` is deprecated and will be removed in Python 3.13.
|
||||
It is untested and undocumented and also not used by :mod:`webbrowser` itself.
|
||||
Patch by Dong-hee Na.
|
||||
|
||||
..
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Remove the untested and undocumented :mod:`webbrowser` :class:`!MacOSX` class, deprecated in Python 3.11.
|
||||
Patch by Hugo van Kemenade.
|
Loading…
Reference in New Issue