[New-bugs-announce] [issue5601] webbrowser doesn't just open browsers

Mitchell Model report at bugs.python.org
Mon Mar 30 05:46:17 CEST 2009

New submission from Mitchell Model <mlm at acm.org>:

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.

assignee: georg.brandl
components: Documentation
messages: 84485
nosy: MLModel, georg.brandl
severity: normal
status: open
title: webbrowser doesn't just open browsers
versions: Python 3.0, Python 3.1

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list