Skip to content

Commit de9ec77

Browse files
committed
gh-137586: Address hugovk review comments
Move plistlib to top-level imports alongside the existing import block. Remove os from the inline import inside _macos_default_browser_bundle_id as it is already imported at module level. Remove the stale '# Maintained by Georg Brandl.' comment. Replace manual warnings.warn() in MacOSXOSAScript.__init__ with warnings._deprecated("webbrowser.MacOSXOSAScript", remove=(3, 17)). Change 'deprecated:: next' to 'deprecated-removed:: next 3.17' in Doc/library/webbrowser.rst. Add MacOSXOSAScript to Doc/deprecations/pending-removal-in-3.17.rst. Add register("MacOSX", None, MacOS('default')) as a backward compatibility alias so webbrowser.get("MacOSX") continues to work.
1 parent 5a4fdad commit de9ec77

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

Doc/deprecations/pending-removal-in-3.17.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Pending removal in Python 3.17
3737
is deprecated and scheduled for removal in Python 3.17.
3838
(Contributed by Stan Ulbrych in :gh:`136702`.)
3939

40+
* :mod:`webbrowser`:
41+
42+
- :class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of
43+
:class:`!webbrowser.MacOS`. (:gh:`137586`)
44+
4045
* :mod:`typing`:
4146

4247
- Before Python 3.14, old-style unions were implemented using the private class

Doc/library/webbrowser.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Notes:
227227
:class:`!MacOS` has been added as a replacement for :class:`!MacOSXOSAScript`,
228228
opening browsers via :program:`/usr/bin/open` instead of :program:`osascript`.
229229

230-
.. deprecated:: next
230+
.. deprecated-removed:: next 3.17
231231
:class:`!MacOSXOSAScript` is deprecated in favour of :class:`!MacOS`.
232232
Using :program:`/usr/bin/open` instead of :program:`osascript` is a
233233
security and usability improvement: :program:`osascript` may be blocked

Lib/webbrowser.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Interfaces for launching and remotely controlling web browsers."""
2-
# Maintained by Georg Brandl.
32

43
import os
4+
import plistlib
55
import shlex
66
import shutil
77
import sys
@@ -493,6 +493,7 @@ def register_standard_browsers():
493493

494494
if sys.platform == 'darwin':
495495
register("MacOS", None, MacOS('default'))
496+
register("MacOSX", None, MacOS('default')) # backward compat alias
496497
register("chrome", None, MacOS('google chrome'))
497498
register("chromium", None, MacOS('chromium'))
498499
register("firefox", None, MacOS('firefox'))
@@ -628,7 +629,7 @@ def _macos_default_browser_bundle_id():
628629
LaunchServices plist is not written until the user explicitly
629630
changes their default browser.
630631
"""
631-
import builtins, plistlib, os
632+
import builtins
632633
plist = os.path.expanduser(
633634
'~/Library/Preferences/com.apple.LaunchServices/'
634635
'com.apple.launchservices.secure.plist'
@@ -692,11 +693,7 @@ def open(self, url, new=0, autoraise=True):
692693
class MacOSXOSAScript(BaseBrowser):
693694
def __init__(self, name='default'):
694695
import warnings
695-
warnings.warn(
696-
"MacOSXOSAScript is deprecated, use MacOS instead.",
697-
DeprecationWarning,
698-
stacklevel=2,
699-
)
696+
warnings._deprecated("webbrowser.MacOSXOSAScript", remove=(3, 17))
700697
super().__init__(name)
701698

702699
def open(self, url, new=0, autoraise=True):

0 commit comments

Comments
 (0)