summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_webbrowser.py4
-rwxr-xr-xLib/webbrowser.py24
2 files changed, 21 insertions, 7 deletions
diff --git a/Lib/test/test_webbrowser.py b/Lib/test/test_webbrowser.py
index 673cc99..dbfd2e5 100644
--- a/Lib/test/test_webbrowser.py
+++ b/Lib/test/test_webbrowser.py
@@ -304,7 +304,7 @@ class ImportTest(unittest.TestCase):
webbrowser = import_helper.import_fresh_module('webbrowser')
try:
browser = webbrowser.get().name
- except (webbrowser.Error, AttributeError) as err:
+ except webbrowser.Error as err:
self.skipTest(str(err))
with os_helper.EnvironmentVarGuard() as env:
env["BROWSER"] = browser
@@ -316,7 +316,7 @@ class ImportTest(unittest.TestCase):
try:
webbrowser.get()
least_preferred_browser = webbrowser.get(webbrowser._tryorder[-1]).name
- except (webbrowser.Error, AttributeError, IndexError) as err:
+ except (webbrowser.Error, IndexError) as err:
self.skipTest(str(err))
with os_helper.EnvironmentVarGuard() as env:
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: