[issue34238] When BROWSER is set on Mac webbrowser.register_standard_browsers doesn't work

Jason report at bugs.python.org
Thu Jul 26 15:55:16 EDT 2018


Jason <jason at theograys.com> added the comment:

Serhiy, I believe you are correct. I updated my local python and it passed.

However, I think there might be a bug with the implementation that doesn't
correctly respect the BROWSER preference. If I do:

```
➜  BROWSER=lynx python3

Python 3.7.0 (default, Jul 23 2018, 20:22:55)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> webbrowser.register_standard_browsers()
>>> webbrowser._tryorder
['MacOSX', 'chrome', 'firefox', 'safari', 'lynx', 'lynx']
>>> webbrowser._browsers
{'macosx': [None, <webbrowser.MacOSXOSAScript object at 0x101c142e8>],
'chrome': [None, <webbrowser.MacOSXOSAScript object at 0x101c14358>],
'firefox': [None, <webbrowser.MacOSXOSAScript object at 0x101d70c50>],
'safari': [None, <webbrowser.MacOSXOSAScript object at 0x101d70cc0>],
'lynx': [None, <webbrowser.GenericBrowser object at 0x101c82048>]}
```
Notice how the webbrowser._tryorder has two 'lynx' items and both of them
are last. If you look at the comment in the code, it says that it should be
prepended to _tryorder because it's the preferred browser. See
https://github.com/python/cpython/blob/56b29b6d6fa3eb32bb1533ee3f21b1e7135648a0/Lib/webbrowser.py#L563

If I change `cmd = _synthesize(cmdline, preferred=False)`, line 566, to
preferred=True then the output is like this:

```
>>> webbrowser._tryorder
['lynx', 'MacOSX', 'chrome', 'firefox', 'safari', 'lynx']
```

Which I believe is closer to being correct based upon the comments in the
code.

Am I wrong about this, and should I open up a new bug report for it?

Thanks.

On Thu, Jul 26, 2018 at 1:49 PM Serhiy Storchaka <report at bugs.python.org>
wrote:

>
> Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
>
> I think it is fixed in issue31014.
>
> ----------
> nosy: +serhiy.storchaka
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <https://bugs.python.org/issue34238>
> _______________________________________
>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34238>
_______________________________________


More information about the Python-bugs-list mailing list