webbrowser.open("./documentation/help.html")-- No Go in Windows
Terry Reedy
tjreedy at udel.edu
Mon Feb 25 00:35:17 EST 2013
On 2/24/2013 4:35 AM, Chris Rebert wrote:
> Sounds like this might be your problem:
> http://bugs.python.org/issue8936
I just closed that issue an invalid. Here is most of what I wrote.
'''
After reading the doc and the code, I am convinced that current behavior
is close to the implied wanted behavior, and that it is not a bug.
The doc says
webbrowser.open(url, new=0, autoraise=True)
Display url using the default browser.
What does 'default browswer' mean? Near the top, the doc says "If the
environment variable BROWSER exists, it is interpreted to override the
platform default list of browsers,". So the 'default browser' is
actually the 'default browser list'. What open() does is to try each in
turn and stop when one says it succeeded. So the doc should say 'using
the first default browser that claims to succeed.'
What does 'default browser list' mean? It depends on the platform *and*
the software loaded on the particular machine when webbrowser is first
imported in a particular instance of the interpreter. The 'platform'
part is in the quote above, the rest is not. I will open a separate doc
issue.
On Windows, the list starts with 'default Windows browser', which calls
os.startfile(), which, I believe, does call the user default browser.
Next is Internet Explorer -- if available at that time on the particular
machine! If the user-default browser rejects the url, then IE is tried.
On my win7 machine today, I have Firefox the default and IE available.
Firefox rejects 127.0.0.1:8080 with an 'Unable to connect' error box. IE
'accepts' it in the sense that it displays an information starting 'The
webpage cannot be displayed'.
'''
For *this* issue, I strongly suspect that Chrome is rejecting the
invalid URL and telling Python so. So IE is tried next (but not first).
> The fix would seem to be ensuring that the URL you pass includes the
> scheme (in your case, "file:").
so that Chrome does not return an error code, in which case IE should
*not* be tried as a backup.
--
Terry Jan Reedy
More information about the Python-list
mailing list