Author terry.reedy
Recipients georg.brandl, terry.reedy
Date 2010-12-31.03:47:29
SpamBayes Score 3.37872e-10
Marked as misclassified No
Message-id <1293767251.94.0.704365544958.issue10799@psf.upfronthosting.co.za>
In-reply-to
Content
webbrowser.open (and two aliases):

1. document return value, which seems to be: True if a browser tab or window is opened, regardless of whether or not the url is found; False otherwise.

2. document that (on Windows, at least) the default browser only gets used if a non .htm(l) url starts with 'www' or 'http:'.

This is true because os.startfile(url) apparently only works if above is true, as required for the Start/Run box to recognize an entry as a url.

In particular, I have Firefox as default and 'www.google.com' and 'http://bugs.python.org' get opened in Firefox (new tab as requested). However, 'google.com' and 'bugs.python.org' open with IE after some delay. [Start/run either opens with Firefox or reports 'cannot find'.]
-----

In the longer run, what I would really like is for webbrowser to be better at using the default or finding executables.

I thought of adding 'http://' if not present but that would disable opening files in a file browser.

I suspect there is a registry entry but do not know what it is. That would also pick up new browswers like Chrome.

It seems to me that the current behavior is a 'limitation' in this code:

    # Detect some common Windows browsers, fallback to IE
    iexplore = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"),
                            "Internet Explorer\\IEXPLORE.EXE")
    for browser in ("firefox", "firebird", "seamonkey", "mozilla",
                    "netscape", "opera", iexplore):
        if _iscommand(browser):
            register(browser, None, BackgroundBrowser(browser))

Firefox is not being recognized as a command because _iscommand('firefox') does not not see firefox.exe as an executable because it only checks _isexecutable() in the hodgepodge list of paths in PATH. At one time (but no longer), executables were ofter put in c:/windows, which by default is in PATH.

Since you hardcoded the default real path for iexplore (C:\\Program Files\\"Internet Explorer\\IEXPLORE.EXE"), you could do the same for other programs: 

firefox = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"), "Mozilla Firefox\\firefox.exe")
History
Date User Action Args
2010-12-31 03:47:32terry.reedysetrecipients: + terry.reedy, georg.brandl
2010-12-31 03:47:31terry.reedysetmessageid: <1293767251.94.0.704365544958.issue10799@psf.upfronthosting.co.za>
2010-12-31 03:47:29terry.reedylinkissue10799 messages
2010-12-31 03:47:29terry.reedycreate