[Patches] [ python-Patches-954628 ] Replacement for webbrowser.py which has problems.

SourceForge.net noreply at sourceforge.net
Sun Mar 20 02:26:04 CET 2005

Patches item #954628, was opened at 2004-05-15 22:02
Message generated for change (Comment added) made by rodsenra
You can respond by visiting: 

Category: Library (Lib)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Michel Van den Bergh (vdbergh)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Replacement for webbrowser.py which has problems.

Initial Comment:
I have been checking out webbrowser.py. Unfortunately
this module has some obvious problems (tested on CVS
version under Linux with mozilla)

(*) If you open an url (with the option "new window")
and the browser is not already running then it opens
*two* windows: the home page and your url. This is
different for example from the default behaviour on
Windows and also quite ugly.

(**) There is another related problem: if you open a
url and the browser is not already running then the
code starts a new browser, sleeps 4 seconds and then
issues a "-remote" command.

Using a timed sleep is very bad programming and
*extremely fragile*. Indeed I had failures because the
delay (PROCESS_CREATION_DELAY) was not long enough. At
the very least the -remote command should be tried a
couple of times.

BUT: there is no reason *at all* to issue a -remote
command in this case. All browsers I know accept a url
as argument. So one can just start a new browser with
the url as argument.

There are two pending patches for webbrowser.py but
they don't address the above problems. Therefore I made
a new version of webbrowser.py (from the latest CVS)
that addresses them.

Along the way I made a few other non-intrusive changes.
They are listed below.

Added PYTHONBROWSER environment variable since Mandrake
already sets BROWSER.

Added opera, epiphany,firefox,firebird. Firebird and
firefox and the rewritten code for Galeon are not tested

Changed default on windows to be "startfile" (instead
of Netscape).

Changed _tryorder on X into something more reasonable
for these days.


Comment By: Rodrigo Dias Arruda Senra (rodsenra)
Date: 2005-03-20 01:26

Logged In: YES 

There is no patch attached, but the whole file was uploaded.
There is already a comment by Oleg Broytmann telling the person 
to re-submit it in as a proper patch.

There are multiple changes in it, perhaps multiples patches.
Each addresing a single change. Some of the proposed changes
are declared untested.

Some changes might be controversial, like using a new
environment variable PYTHONBROWSER prior to checking
BROWSER.  There are no references to this being discussed in

I recommend closing 954628.


Comment By: Oleg Broytmann (phd)
Date: 2005-03-19 20:48

Logged In: YES 

IWBN to have exactly one patch (I do not understand which
one of those two is THE patch) in "context diff" format.
Please delete the attachments and resubmit the patch.

The idea of running "-remote" and then starting the program
if it hadn't been started is fine!

Why to add "-iconic" for Netscape if not autoraise? "Not
autoraise" means "do not change z-order of the window" but
that does not neccessary implies "leave the window iconic"
even less "make the window iconic". When you run a new
program "not autoraise" should be ignore, as far as I


Comment By: Martin Franklin (mfranklin1)
Date: 2004-11-11 10:05

Logged In: YES 

Great work... couple of points I just tested on my fedora c2
box (with firefox & opera installed...)  The try order did
not include firefox.  

Also I believe (at least on my system) opera can be treated
just like the 
netscape browsers, it supports the same command line flags.

As to the tryorder *I* would personally have firefox up
front because if you 
have it installed the chances are you want to use it instead
of mozzilla (same 
goes for opera)


You can respond by visiting: 

More information about the Patches mailing list