python / cpython

The Python programming language
https://www.python.org
Other
63.08k stars 30.21k forks source link

webbrowser BROWSER with MacOSXOSAScript type #75529

Closed 245970fb-548b-43b7-af0e-b4323a8475aa closed 10 months ago

245970fb-548b-43b7-af0e-b4323a8475aa commented 7 years ago
BPO 31348
Nosy @michael-lazar

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['3.7', 'type-bug', 'library'] title = 'webbrowser BROWSER with MacOSXOSAScript type' updated_at = user = 'https://github.com/michael-lazar' ``` bugs.python.org fields: ```python activity = actor = 'michael-lazar' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'michael-lazar' dependencies = [] files = [] hgrepos = [] issue_num = 31348 keywords = [] message_count = 1.0 messages = ['301294'] nosy_count = 1.0 nosy_names = ['michael-lazar'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue31348' versions = ['Python 2.7', 'Python 3.6', 'Python 3.7'] ```

245970fb-548b-43b7-af0e-b4323a8475aa commented 7 years ago

Hello,

I have found that [1] is an open issue, but I have discovered what appears to be a completely separate bug than the one described in that ticket. The issue is that there is no way to specify a MacOSXOSAScript browser using the BROWSER variable. The _synthesize() command fails at the "if not shutil.which(cmd)" line, because OSAScript browsers are not commands in the system path. As a result, the value specified by BROWSER will get re-mapped to a GenericBrowser type, which is useless for most people on macOS.

Here's an example:

$ BROWSER=firefox python3
Python 3.6.1 (default, Apr  4 2017, 09:36:47)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> for name in webbrowser._tryorder:
...     print('%s: %s' % (name, webbrowser._browsers[name.lower()]))
...
firefox: [None, <webbrowser.GenericBrowser object at 0x100f35198>]
MacOSX: [None, <webbrowser.MacOSXOSAScript object at 0x100f35748>]
chrome: [None, <webbrowser.MacOSXOSAScript object at 0x100f76f28>]
firefox: [None, <webbrowser.GenericBrowser object at 0x100f35198>]
safari: [None, <webbrowser.MacOSXOSAScript object at 0x100f76ef0>]
links: [None, <webbrowser.GenericBrowser object at 0x100e67b70>]
elinks: [None, <webbrowser.Elinks object at 0x100f17fd0>]
lynx: [None, <webbrowser.GenericBrowser object at 0x100f76048>]
w3m: [None, <webbrowser.GenericBrowser object at 0x100f76588>]

Note that on macOS, firefox is defined in the webbrowser module as

register("firefox", None, MacOSXOSAScript('firefox'), -1)

[1] http://bugs.python.org/issue24955

arhadthedev commented 1 year ago

Bumping because gh-104804 makes MacOSXOSAScript the only macOS-specific option available.

arhadthedev commented 1 year ago

I have found that [1] is an open issue, but I have discovered what appears to be a completely separate bug than the one described in that ticket.

[1] is gh-69143, in case of its PR somehow reusable here.

ronaldoussoren commented 10 months ago

If I understand the discussion correctly this issue has been fixed in the meantime.

What I checked:

I don't have other browsers than Safari and Safari's tech preview on my system and therefore haven't checked that setting BROWSER to firefox or chrome will actually use those browsers, but other than that everything appears to work fine.

Please respond with a clear description of the problem if there are still problems with using the BROWSER in the environment.