This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: webbrowser doesn't just open browsers
Type: Stage:
Components: Documentation Versions: Python 3.0, Python 3.1
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: MLModel, georg.brandl
Priority: normal Keywords:

Created on 2009-03-30 03:46 by MLModel, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unnamed MLModel, 2009-04-01 02:37
unnamed MLModel, 2009-04-01 03:55
unnamed MLModel, 2009-04-01 14:20
Messages (7)
msg84485 - (view) Author: Mitchell Model (MLModel) Date: 2009-03-30 03:46
There is a problem with the documentation of the webbrowser module: 
opening a URL doesn't necessarily open it in a browser. The 
documentation of the open function and method should say that the URL is 
opened in whatever application the system chooses based on 
considerations such as the type of URL, an application assigned to the 
file, and the application assigned to the file's type (extension).

Here's why:

The documentation of module webbrowser, as well as the name of the 
module itself, only mentions browsers as what opens the given URL. 
However, on some platforms (Mac OS X, e.g.) if things are configured so 
there is a default application associated with a particular file 
extension, the webbrowser functions will open a path to a file in the 
application associated with it's file type rather than a browser. This 
is true whether or not "file://" precedes the file path in the "URL". 
For example, if .py files are set to open in IDLE, 
webbrowser.open('/fullpath/to/file.py') will open /fullpath/to/file.py 
in IDLE. It's even possible to assign one browser to open .htm files and 
another to open .html files.

It is also possible on some platforms (Mac, again) to assign a default 
application to files of a particular extension but assign a different 
application to specific files with that extension.

Applications can also be assigned to URL types. For instance, you could 
have an application that isn't really a browser open ftp:// URLs. (This 
also can happen when you download a file from a browser and the task is 
turned over to a download application such as Speed Download or 
Interarchy on a Mac.)

The real problem here is that some platforms have extended the idea of 
opening a URL (including a bare file path interpreted as a file:// URL) 
beyond browsers per se. In a sense the entire terminology of this module 
is suspect, despite its obvious intent. Although not a serious 
suggestion, it would more accurately be termed the urlopen module.
msg84906 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-03-31 21:09
I'm inclined not to document that. webbrowser is meant for URLs, the
behavior if you call it with file names is undefined.
msg84964 - (view) Author: Mitchell Model (MLModel) Date: 2009-04-01 02:37
The problem is not so much that I think people should use it for file 
URLs, it's that the behavior when they do can be quite confusing. 
Perhaps a note that webbrowser is not meant for file URLs and that 
it's behavior is undefined if it is?
-- 
-- 

         --- Mitchell
msg84967 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-01 03:01
That would be nice.
msg84975 - (view) Author: Mitchell Model (MLModel) Date: 2009-04-01 03:55
whoops

Sorry for the garbage in the previous message.
-- 
-- 

         --- Mitchell
msg85014 - (view) Author: Mitchell Model (MLModel) Date: 2009-04-01 14:20
Never mind about the garbage -- I was looking at weird HTML in the 
copy of the message I received but it didn't make it into the entry 
on this page. I should have looked first.
-- 
-- 

         --- Mitchell
msg85394 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-04 13:45
Updated docs in r71150.
History
Date User Action Args
2022-04-11 14:56:47adminsetgithub: 49851
2009-04-04 13:45:59georg.brandlsetstatus: pending -> closed

messages: + msg85394
2009-04-01 14:20:37MLModelsetfiles: + unnamed

messages: + msg85014
2009-04-01 03:55:01MLModelsetfiles: + unnamed

messages: + msg84975
2009-04-01 03:01:15georg.brandlsetmessages: + msg84967
2009-04-01 02:37:01MLModelsetfiles: + unnamed

messages: + msg84964
2009-03-31 21:09:53georg.brandlsetstatus: open -> pending
resolution: wont fix
messages: + msg84906
2009-03-30 03:46:16MLModelcreate