Issue10799
Created on 2010-12-31 03:47 by terry.reedy, last changed 2011-08-13 09:58 by ezio.melotti.
| Messages (4) | |||
|---|---|---|---|
| msg124949 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2010-12-31 03:47 | |
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") |
|||
| msg126056 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2011-01-12 00:23 | |
> I thought of adding 'http://' if not present but that would disable opening files in a file browser. I think that’s a Windows-specific behavior, not a promise of the *web*browser module. |
|||
| msg126921 - (view) | Author: Senthil Kumaran (orsenthil) * ![]() |
Date: 2011-01-24 11:14 | |
On Wed, Jan 12, 2011 at 12:23:31AM +0000, Éric Araujo wrote: > > I thought of adding 'http://' if not present but that would > > disable opening files in a file browser. > > I think that’s a Windows-specific behavior, not a promise of the > *web*browser module. If being lenient with URLs which do not start with http:// is the idea, then webbrowser module can do explicitly add that. Having a default protocol option in the open method and we can set it to 'http'. Many WWW browsers do that. But, I agree that it should not be related to Windows file-browser behavior (for whatever it's behavior is). |
|||
| msg137614 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2011-06-04 00:13 | |
Upon further experimentation, I realize that I can only open in Firefox because I have it set as my default browser. It would otherwise be inaccessible because it is not in the _browser registry. It also appears that I cannot intentionally use Internet Explorer because it also in not registered (except under the full path names used as a backup).
>>> webbrowser._browsers
{'windows-default': [<class 'webbrowser.WindowsDefault'>, None], 'c:\\program files\\internet explorer\\iexplore.exe': [None, <webbrowser.BackgroundBrowser object at 0x01000ED0>]}
If I understand the Windows code quoted before, the Class Names in the table would be different (BackgroundBrowser) on Windows if it did work.
Related issues
#8232 webbrowser.open incomplete on Windows
#8936 webbrowser regression on windows
#12237 Document how to open non-default webbrowser
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2011-08-13 09:58:06 | ezio.melotti | set | nosy:
+ ezio.melotti |
| 2011-06-04 00:13:33 | terry.reedy | set | type: behavior messages: + msg137614 components: + Documentation title: Improve webbrowser.open doc (and, someday, behavior?) -> Improve webbrowser (.open) doc and behavior |
| 2011-06-04 00:12:54 | terry.reedy | link | issue12237 superseder |
| 2011-01-24 11:14:06 | orsenthil | set | nosy:
+ orsenthil messages: + msg126921 |
| 2011-01-12 00:23:26 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg126056 |
| 2010-12-31 03:47:29 | terry.reedy | create | |
