New submission from Ilya Grigoriev <ily...@gmail.com>:

The object `webbrowser.get()` returns has, and had for a long time, a useful 
but undocumented field `name`. I wonder if it would be OK to document it as 
something like `a system-dependent name for the browser`. This would go here:

https://docs.python.org/3/library/webbrowser.html#browser-controller-objects

The reason I'd like this is so that I can write code like the following:

```python
# In Crostini Chrome OS Linux, the default browser is set to an
# intermediary called `garcon-url-handler`.
# It opens URLs in Chrome running outside the linux VM. This 
# browser does not have access to the Linux filesystem. Some references:
# 
https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/garcon/#opening-urls
# https://source.chromium.org/search?q=garcon-url-handler

if "garcon-url-handler" in webbrowser.get().name:
  webbrowser.open("http://external-url.com/docs.html";)
else:
  webbrowser.open("file:///usr/share/doc/docs.html")
```

This would work correctly, even if the user has installed a browser native to 
the Linux VM and put it into their `BROWSER` environment variable. I don't know 
a better way to achieve the same effect.

Some references to where the `name` field was introduced:

https://bugs.python.org/issue754022

https://github.com/python/cpython/commit/e8f244305ef4f257f6999b69601f4316b31faa5e

----------
assignee: docs@python
components: Documentation, Library (Lib)
messages: 388218
nosy: docs@python, ilyagr
priority: normal
severity: normal
status: open
title: Document the `controller.name` field in `webbrowser` module
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43424>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to