classification
Title: webbrowser.py triggers unwanted XQuartz startup
Type: resource usage Stage: patch review
Components: Library (Lib), macOS Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: hans-meine, ned.deily, ronaldoussoren, terry.reedy
Priority: normal Keywords: patch

Created on 2021-02-03 09:21 by hans-meine, last changed 2021-02-08 09:04 by terry.reedy.

Pull Requests
URL Status Linked Edit
PR 24480 open ronaldoussoren, 2021-02-08 08:43
Messages (6)
msg386182 - (view) Author: hans.meine (hans-meine) Date: 2021-02-03 09:21
For a long time, I wondered why opening Jupyter notebooks through nbopen always led to XQuartz starting.  Now, I found the reason: nbopen uses webbrowser.py to open a web page, and webbrowser.py sees the `DISPLAY` variable being set and calls xdg-settings (which I installed via the xdg-utils port / MacPorts).

Apparently, in order to be able to fire up XQuartz on demand and to allow people starting X11 applications, `DISPLAY` is set to a string like `/private/tmp/com.apple.launchd.<somecode>/org.xquartz:0`.

I am using Safari and find this starting of XQuartz undesirable (causes a delay, uses system resources, leads to a new running program in the Dock / task switcher). On the other hand I can totally understand that the code makes sense.

As a workaround, I can unset DISPLAY, or uninstall xdg-utils (although it is useful, and may be a dependency of other ports), but I thought I should also bring it up here for discussion.
msg386553 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-02-06 08:44
3.7 is a few years old and only gets security fixes.  Can you either test on current releases or whether code is still same?
msg386555 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2021-02-06 11:25
The same code is present in trunk. 

I'm in favour of disabling usage of X11 browsers of macOS, that's almost certainly not what users want.

I no longer have XQuartz installed on my machine, but when I did I only used it for running X11 GUIs on remote Linux systems.

What I'm not entirely sure about: is this something we should back port or just apply to the trunk (3.10)? This is a behaviour change and as such I'd be inclined to only apply to trunk.
msg386557 - (view) Author: hans.meine (hans-meine) Date: 2021-02-06 12:18
I was trying to be very honest, because I am still running 3.7 for production. However, I have carefully checked and the webbrowser.py has only seen (clearly) unrelated changes.
msg386623 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2021-02-08 08:44
I've created a PR for this. 

Open question: Is this a bug fix (with back ports to 3.9 and 3.8) or a feature  (no back ports)?
msg386625 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-02-08 09:04
webbrowser is 'generous' at to what browsers it will open, some of which are not what hardly anyone would want.  So I would call this an 'enhancement' (really 'disenchantment', like all removals;-) unless there were a technical reason other than those given for the exclusion.
History
Date User Action Args
2021-02-08 09:04:26terry.reedysetmessages: + msg386625
2021-02-08 08:44:31ronaldoussorensetmessages: + msg386623
2021-02-08 08:43:27ronaldoussorensetkeywords: + patch
stage: patch review
pull_requests: + pull_request23272
2021-02-06 12:18:37hans-meinesetmessages: + msg386557
2021-02-06 11:25:33ronaldoussorensetmessages: + msg386555
versions: + Python 3.8, Python 3.9, Python 3.10, - Python 3.7
2021-02-06 08:44:20terry.reedysetnosy: + terry.reedy
messages: + msg386553
2021-02-03 09:21:34hans-meinecreate