webbrowser module bug?

Ron Adam rrr at ronadam.com
Fri May 25 16:31:17 EDT 2007


Ron Adam wrote:

> Got it.
> 
>     It looks like the problem started when I told firefox to make itself 
> the default browser.  That changed the way webbrowser.py figured out the 
> browser to use.  So instead of trying them in order, it asked the gnome 
> configure tool for it.
> 
> def register_X_browsers():
>      # The default Gnome browser
>      if _iscommand("gconftool-2"):
>          # get the web browser string from gconftool
>          gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command 
> 2>/dev/null'
>          out = os.popen(gc)
>          commd = out.read().strip()
>          retncode = out.close()
> 
> 
> After this commd is:
> 
>      '/usr/lib/firefox/firefox "%s"'
> 
> It's then split, but the quotes aren't removed.  I'm not sure why this 
> doesn't show up in 2.6.  Maybe it's been fixed there already.

A bit more follow up... so others can find this and avoid a lot of 
debugging, head scratching, computer smashing or worse.

Reseting the default browser with the gnome default application window 
confirmed this.  The browser selection can either have the quotes around 
the args "%s" paremteter, or not depending on how and what sets it.

Seems to me it should be quoted unless spaces in path names are never a 
problem in Linux.  So this could be both a python bug and a Gnome desktop 
bug.  Firefox probably does the right thing by putting the quotes around 
it, but that causes problems for webbrowser.py, which doesn't expect them.

Since the python trunk (2.6) has been changed to get the browser name in a 
different way, it won't be a problem for python 2.6.

To check the args parameter or reset the default browser in the gnome 
desktop, use the gnome default application panel.

     $ gnome-default-applications-properties

You can then either remove the extra quotes from the "%s" or reset the browser.


Cheers,
    Ron








More information about the Python-list mailing list