GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-137586: Replace 'osascript' with 'open' on macOS in webbrowser by secengjeff · Pull Request #146439 · python/cpython Conversation
|
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…press Sphinx lookup
- Add test_default to MacOSXTest asserting webbrowser.get() returns MacOSX - Remove test_default from MacOSXOSAScriptTest (no longer the registered default) - Suppress DeprecationWarning in MacOSXOSAScriptTest setUp and test_explicit_browser using warnings.catch_warnings() so tests for OSAScript behaviour still run cleanly - Add warnings import
…ia OS handler For non-http(s) URLs (e.g. file://), /usr/bin/open dispatches via the OS file handler, which would launch an .app bundle rather than open it in a browser. Fix this by routing non-http(s) URLs through the browser explicitly using /usr/bin/open -b <bundle-id>. Named browsers use a static bundle ID map (Chrome, Firefox, Safari, Chromium, Opera, Edge). Unknown named browsers fall back to -a. For the default browser, the bundle ID is resolved at runtime via the Objective-C runtime using NSWorkspace.URLForApplicationToOpenURL, the same lookup MacOSXOSAScript performed via AppleScript. Falls back to direct open if ctypes is unavailable. http/https URLs with the default browser continue to use /usr/bin/open directly, as macOS always routes these to the registered browser.
…ult_browser_bundle_id NSWorkspace is an AppKit class and is not registered in the ObjC runtime until AppKit is loaded. Without the explicit LoadLibrary call, objc_getClass returns nil for NSWorkspace, causing the entire lookup to silently fall back to /usr/bin/open without -b.
| (4) | ||
| Only on iOS. | ||
|
|
||
| .. deprecated:: 3.14 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
3.15
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| .. deprecated:: 3.14 | |
| .. deprecated:: next |
And precede this deprecated block with a versionadded for the new class, and move both after versionchanged:: 3.13 below.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Also the MacOSXOSAScripts in the table above need updating, and should we also add chrome and firefox (with note (3)) as also returning the new class?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this PR.
The direct security issue can be fixed by changing the invocation of osascript to /usr/bin/osascript. Blocking osascript while allowing usage of Python is IMHO security theatre.
On modernist systems (macOS 10.15 or later) it is probably possible to just use NSWorkspace directly: it has all the moving peaces to implement what we need for webbrowser.open although I haven't thought through the implications of doing this yet. In particular, -[NSWorkpace openURLs:withApplicationAtURL:configuration:completionHandler:] is asynchronous which makes it harder to report errors.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| (4) | ||
| Only on iOS. | ||
|
|
||
| .. deprecated:: 3.14 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| .. deprecated:: 3.14 | |
| .. deprecated:: next |
And precede this deprecated block with a versionadded for the new class, and move both after versionchanged:: 3.13 below.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| (4) | ||
| Only on iOS. | ||
|
|
||
| .. deprecated:: 3.14 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Also the MacOSXOSAScripts in the table above need updating, and should we also add chrome and firefox (with note (3)) as also returning the new class?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…_standard_browsers on macOS
These browsers were present in MacOSX._BUNDLE_IDS but not registered,
causing webbrowser.get("opera") etc. to raise Error: could not locate
runnable browser.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ib to address memory and os.fork() concerns
…j3SkOm.rst Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
…Brave
Return 'com.apple.Safari' instead of None when the LaunchServices plist is
absent (fresh installs never write it). None caused the non-http branch to
fall back to bare '/usr/bin/open <url>', bypassing -b and triggering the OS
file handler. Addresses gpshead's CHANGES_REQUESTED.
Fix infinite recursion: webbrowser's module-level open() shadowed
builtins.open, so open(plist, 'rb') called webbrowser.open() recursively
on every non-http/https URL. Use builtins.open() explicitly.
Narrow 'except Exception' to '(OSError, KeyError, ValueError)'. Addresses
hugovk's review comment.
Add 'brave browser': 'com.brave.Browser' to _BUNDLE_IDS and register it
so webbrowser.get('brave') works and Brave uses precise -b dispatch instead
of the name-based -a fallback.
Tested locally against Safari, Chrome, Firefox, Opera, Edge, and Brave
with https, http, and file:// URLs. 29/29 checks pass.
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.
|
I have made the requested changes; please review again |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @ronaldoussoren, @gpshead: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just some little nits.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * :mod:`webbrowser`: | ||
|
|
||
| - :class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of | ||
| :class:`!webbrowser.MacOS`. (:gh:`137586`) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please list alphabetically, after typing
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| import builtins # because we override open | ||
| import os | ||
| lazy import plistlib |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Oh, and please add to https://docs.python.org/3.15/whatsnew/3.15.html We can have one entry under "Improved modules" and another under "New deprecations", and can largely be the same as the two NEWS entries. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Move webbrowser entry in Doc/deprecations/pending-removal-in-3.17.rst to after typing, to maintain alphabetical order. Move import plistlib to after import threading, per isort/Ruff style of placing stdlib imports after the main import block. Fix :class:`!MacOSX` -> :class:`!MacOS` in the Library NEWS entry. Remove extra blank line in MacOSXOSAScriptTest.mock_popen. Add webbrowser entries to Doc/whatsnew/3.15.rst: one under "Improved modules" describing the new MacOS class, and one under "New deprecations" for MacOSXOSAScript scheduled removal in 3.17.
Use :class:`!webbrowser.MacOS` and :class:`!webbrowser.MacOSXOSAScript` with the ! prefix to suppress cross-reference lookup for classes not yet present in upstream.
Documentation build overview
89 files changed ·
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thank you! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A bot is credited as co-author in the commit. Was that wanted? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.