diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2021-12-30 01:30:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-30 01:30:13 (GMT) |
commit | d12bec69931503be78cd555cf7bc22ad6f4f2bd5 (patch) | |
tree | 5da71de0ca31566290cd80eb2cee9e98676c64cd /Lib/webbrowser.py | |
parent | 8e11237c5d24e649b26cc928b52bc37f2fde9c7a (diff) | |
download | cpython-d12bec69931503be78cd555cf7bc22ad6f4f2bd5.zip cpython-d12bec69931503be78cd555cf7bc22ad6f4f2bd5.tar.gz cpython-d12bec69931503be78cd555cf7bc22ad6f4f2bd5.tar.bz2 |
bpo-43424: Deprecate `webbrowser.MacOSXOSAScript._name` attribute (GH-30241)
Diffstat (limited to 'Lib/webbrowser.py')
-rwxr-xr-x | Lib/webbrowser.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 3244f20..02d2036 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -666,19 +666,33 @@ if sys.platform == 'darwin': return not rc class MacOSXOSAScript(BaseBrowser): - def __init__(self, name): - self._name = name + def __init__(self, name='default'): + super().__init__(name) + + @property + def _name(self): + warnings.warn(f'{self.__class__.__name__}._name is deprecated in 3.11' + f' use {self.__class__.__name__}.name instead.', + DeprecationWarning, stacklevel=2) + return self.name + + @_name.setter + def _name(self, val): + warnings.warn(f'{self.__class__.__name__}._name is deprecated in 3.11' + f' use {self.__class__.__name__}.name instead.', + DeprecationWarning, stacklevel=2) + self.name = val def open(self, url, new=0, autoraise=True): - if self._name == 'default': + if self.name == 'default': script = 'open location "%s"' % url.replace('"', '%22') # opens in default browser else: - script = ''' + script = f''' tell application "%s" activate open location "%s" end - '''%(self._name, url.replace('"', '%22')) + '''%(self.name, url.replace('"', '%22')) osapipe = os.popen("osascript", "w") if osapipe is None: |