From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 7 Apr 2026 03:35:21 +0000 (+0200) Subject: [3.10] gh-137586: Open external osascript program with absolute path (GH-137584)... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e70ff776fdf8e239060b714ff4edcad3794e1996;p=thirdparty%2FPython%2Fcpython.git [3.10] gh-137586: Open external osascript program with absolute path (GH-137584) (#148177) Co-authored-by: Fionn <1897918+fionn@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- diff --git a/Lib/test/test_webbrowser.py b/Lib/test/test_webbrowser.py index a3b31f169d72..c9f8f1bb8f16 100644 --- a/Lib/test/test_webbrowser.py +++ b/Lib/test/test_webbrowser.py @@ -267,7 +267,7 @@ class MacOSXOSAScriptTest(unittest.TestCase): url = "https://python.org" self.browser.open(url) self.assertTrue(self.popen_pipe._closed) - self.assertEqual(self.popen_pipe.cmd, "osascript") + self.assertEqual(self.popen_pipe.cmd, "/usr/bin/osascript") script = self.popen_pipe.pipe.getvalue() self.assertEqual(script.strip(), f'open location "{url}"') diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py index caea022da4a6..40ebcb8c90b8 100755 --- a/Lib/turtledemo/__main__.py +++ b/Lib/turtledemo/__main__.py @@ -137,7 +137,7 @@ class DemoWindow(object): # so that our menu bar appears. subprocess.run( [ - 'osascript', + '/usr/bin/osascript', '-e', 'tell application "System Events"', '-e', 'set frontmost of the first process whose ' 'unix id is {} to true'.format(os.getpid()), diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 98904163c28c..866633790860 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -694,7 +694,7 @@ if sys.platform == 'darwin': end '''%(self._name, url.replace('"', '%22')) - osapipe = os.popen("osascript", "w") + osapipe = os.popen("/usr/bin/osascript", "w") if osapipe is None: return False diff --git a/Misc/NEWS.d/next/macOS/2025-10-17-01-07-03.gh-issue-137586.kVzxvp.rst b/Misc/NEWS.d/next/macOS/2025-10-17-01-07-03.gh-issue-137586.kVzxvp.rst new file mode 100644 index 000000000000..8e42065392a2 --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2025-10-17-01-07-03.gh-issue-137586.kVzxvp.rst @@ -0,0 +1 @@ +Invoke :program:`osascript` with absolute path in :mod:`webbrowser` and :mod:`!turtledemo`.