mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-113539: Enable using `$BROWSER
` to reorder default seach order in webbrowser.py (#113561)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
1a70f66ea8
commit
25e49841e3
4 changed files with 43 additions and 4 deletions
|
@ -482,10 +482,10 @@ def register_standard_browsers():
|
|||
|
||||
if sys.platform == 'darwin':
|
||||
register("MacOSX", None, MacOSXOSAScript('default'))
|
||||
register("chrome", None, MacOSXOSAScript('chrome'))
|
||||
register("chrome", None, MacOSXOSAScript('google chrome'))
|
||||
register("firefox", None, MacOSXOSAScript('firefox'))
|
||||
register("safari", None, MacOSXOSAScript('safari'))
|
||||
# OS X can use below Unix support (but we prefer using the OS X
|
||||
# macOS can use below Unix support (but we prefer using the macOS
|
||||
# specific stuff)
|
||||
|
||||
if sys.platform == "ios":
|
||||
|
@ -559,6 +559,19 @@ def register_standard_browsers():
|
|||
# Treat choices in same way as if passed into get() but do register
|
||||
# and prepend to _tryorder
|
||||
for cmdline in userchoices:
|
||||
if all(x not in cmdline for x in " \t"):
|
||||
# Assume this is the name of a registered command, use
|
||||
# that unless it is a GenericBrowser.
|
||||
try:
|
||||
command = _browsers[cmdline.lower()]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
else:
|
||||
if not isinstance(command[1], GenericBrowser):
|
||||
_tryorder.insert(0, cmdline.lower())
|
||||
continue
|
||||
|
||||
if cmdline != '':
|
||||
cmd = _synthesize(cmdline, preferred=True)
|
||||
if cmd[1] is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue