'new' and 'autoraise' arguments to webbrowser.open() are eaten by gnome-open

Bug #605462 reported by Leonard Richardson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
launchpadlib
Triaged
Low
Unassigned

Bug Description

I'm not filing this as a bug against gnome-open or webbrowser because individually they behave reasonably given their designs. The problem is their combination. I'm filing this bug in one place where the combination causes a problem.

gnome-open is designed to abstract away the differences between desktop applications. You can pass any file or URL into gnome-open and it will figure out the appropriate application and open that application with the file/URL.

The webbrowser module is designed to abstract away the different between web browsers. You pass a URL into webbrowser.open() and it will open that URL in the user's preferred browser. webbrowser.open has two arguments besides the URL: 'new' and 'autoraise'. These arguments are translated into command-line arguments to the preferred browser, assuming the browser has such command-line arguments.

Firefox has support for webbrowser's 'new' argument: you can use the command-line arguments -new-window or -new-tab to open a URL in a new window or tab. Firefox used to support 'autoraise' with the -raise argument--i'm pretty sure that argument is no longer supported, but I know that my computer behaves differently from most peoples' in this manner. Anyway, webbrowser still passes that argument in, just in case you're using an old version of Firefox or something.

That's the wonderful world of Firefox. But, gnome-open doesn't support any of these command-line arguments, because it's too generic to know about windows or tabs. The application it ends up opening might not have any notion of windows or tabs. And on a stock Ubuntu system, gnome-open is the "browser" that the webbrowser module detects and invokes.

So, webbrowser sees they you're using gnome-open, and drops 'new' and 'autoraise' because gnome-open doesn't support them. Then gnome-open turns right around and opens Firefox, which supports at least -new-window or -new-tab. But there's no way to get that information through gnome-open into Firefox.

If there were some gnome-open equivalent of 'which' that let you know which program _would_ be invoked to handle a particular URL, we could see whether that program happened to be Firefox and invoke it with appropriate arguments. As it is, I don't see a good option besides trying Firefox (currently the most popular option) first and falling back to gnome-open.

Revision history for this message
Markus Korn (thekorn) wrote :

In one of my scripts I've a similar issue where I need to know which browser will be used by the webbrowser modul, and I also need to modifie webbrowser._tryorder, see the attached file for how I'm doing this.

Markus

Gary Poster (gary)
Changed in launchpadlib:
status: New → Triaged
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.