[Python-Dev] Change 'env var BROWSER override' semantics in webbrowser.py

Rodrigo Dias Arruda Senra rodsenra at gpr.com.br
Fri Mar 18 21:56:17 CET 2005


I propose a small change in webbrowse.py module.
At the present time:

Under Unix, if the environment variable BROWSER exists, it is 
interpreted to override the platform default list of browsers,...
(extract from Python-2.4/Doc/html/lib/module-webbrowser.html)

I propose the following change:

--- webbrowser.py       2005-03-18 17:43:58.736854784 -0300
+++ webbrowser.py.new   2005-03-18 17:29:57.016815680 -0300
@@ -355,7 +355,7 @@
  if "BROWSER" in os.environ:
      # It's the user's responsibility to register handlers for any unknown
      # browser referenced by this value, before calling open().
-    _tryorder = os.environ["BROWSER"].split(os.pathsep)
+    _tryorder = os.environ["BROWSER"].split(os.pathsep) + _tryorder

  for cmd in _tryorder:
      if not cmd.lower() in _browsers:


This changes the semantics a bit, but in a positive way:

   - When the environment variable BROWSER is messed up, there is
     no reason not to try the other detected browser alternatives
   - If the BROWSER variable is Ok, than it is respected

If nobody stand against it, or would like to propose an alternative
(optimized) implementation, I can submit a patch to sf to alter both
code and documentation.

I'd appreciate to know if you consider this a bug or a new feature ?
I consider this a bug:
The webbrowser module provides a very high-level interface to allow 
displaying Web-based documents to users. The controller objects are easy 
to use and are platform-independent. Under most circumstances, simply 
calling the open() function from this module will do the right thing.
(extract from Python-2.4/Doc/html/lib/module-webbrowser.html)

Ignoring valid *already* detected browsers, due to a broken environment 
variable does not sound like _do the right thing_. <wink>


Rodrigo Senra
MSc Computer Engineer     rodsenra at gpr.com.br
GPr Sistemas Ltda       http://www.gpr.com.br

More information about the Python-Dev mailing list