[New-bugs-announce] [issue35308] webbrowser regression: BROWSER env var not respected

Zhiming Wang report at bugs.python.org
Sat Nov 24 10:26:41 EST 2018


New submission from Zhiming Wang <zmwangx at gmail.com>:

This is a regression in Python 3.7:

    $ BROWSER=w3m python3.6 -c 'import sys; import webbrowser; print(sys.version); print(webbrowser.get()); print(webbrowser._tryorder)'
    3.6.7 (default, Nov 24 2018, 09:47:01)
    [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)]
    <webbrowser.GenericBrowser object at 0x1066207f0>
    ['w3m', 'MacOSX', 'chrome', 'firefox', 'safari', 'w3m']

    $ BROWSER=w3m python3.7 -c 'import sys; import webbrowser; print(sys.version); print(webbrowser.get()); print(webbrowser._tryorder)'
    3.7.1 (default, Nov 24 2018, 09:35:18)
    [Clang 10.0.0 (clang-1000.11.45.5)]
    <webbrowser.MacOSXOSAScript object at 0x1061fe828>
    ['MacOSX', 'chrome', 'firefox', 'safari', 'w3m', 'w3m']

Note how Python 3.7.1 webbrowser decides to choose MacOSX as the default although BROWSER is explicitly set to w3m. (The above code does not run on Python 3.7.0 due to bpo-31014).

This is because of misinterpretation of the `preferred` kwarg when bpo-31014 was fixed. See https://github.com/python/cpython/commit/25b804a9c21c735ce322877f105ebab2539ccfc1#diff-546766353a40839aa72374ecca5b0925R566. Browsers in BROWSER should be registered as `preferred=True` instead.

----------
components: Library (Lib)
messages: 330377
nosy: zmwangx
priority: normal
severity: normal
status: open
title: webbrowser regression: BROWSER env var not respected
type: behavior
versions: Python 3.7, Python 3.8

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


More information about the New-bugs-announce mailing list