[Python-bugs-list] [ python-Bugs-495695 ] webbrowser.py: selection of browser

noreply@sourceforge.net noreply@sourceforge.net
Wed, 09 Jan 2002 06:28:53 -0800


Bugs item #495695, was opened at 2001-12-20 16:56
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=495695&group_id=5470

Category: Python Library
>Group: None
Status: Open
Resolution: Invalid
>Priority: 7
Submitted By: Matthias Klose (doko)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: webbrowser.py: selection of browser

Initial Comment:
[please CC 121737@bugs.debian.org on replies; complete 
report can be found at http://bugs.debian.org/121737 ]

webbrowser.py tries hard to select correct browsers 
and then wastes it

The culprit is the last loop, registering everything 
possible.
I'm not sure, but wasn't it supposed to run only in 
the environ["BROWSER"]
case like this?:

-----diff start-----
--- /usr/lib/python2.1/webbrowser.py	Sun Nov 11 
18:23:54 2001
+++ /tmp/webbrowser.py	Thu Nov 29 17:40:46 2001
@@ -305,11 +305,10 @@
     # 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(":")
-
-for cmd in _tryorder:
-    if not _browsers.has_key(cmd.lower()):
-        if _iscommand(cmd.lower()):
-            register(cmd.lower(), None, GenericBrowser
("%s %%s" % cmd.lower()))
+    for cmd in _tryorder:
+        if not _browsers.has_key(cmd.lower()):
+            if _iscommand(cmd.lower()):
+                register(cmd.lower(), None, 
GenericBrowser("%s %%s" % cmd.lower()))

 _tryorder = filter(lambda x: _browsers.has_key(x.lower
())
                    or x.find("%s") > -1, _tryorder)
-----diff end-----


----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-01-09 06:28

Message:
Logged In: YES 
user_id=3066

Sounds painful, but I can't look at it right now (though I
don't think it will be hard to fix).  I've bumped the
priority up and set the tracker fields to reasonable values
for this report.

I'll need to be careful about testing this with & without
$BROWSER both on a console and under X.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-01-09 05:57

Message:
Logged In: YES 
user_id=6380

If your real complaint is that you are not running under X
yet it tries to start Mozilla, please say so. If that's the
case, we have to figure out where the bug is.

reopening and assigning to Fred Drake -- I don't follow the
login in the module and the use of the _tryorder and
_browsers variable is not documented very well.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2002-01-09 02:23

Message:
Logged In: NO 

But it is the other way around. Earlier you have:
if os.environ.get("TERM") or os.environ.get("DISPLAY"):
    _tryorder = ("mozilla","netscape","kfm","grail","links","lynx","w3m")

So _tryorder is _full_ of browsers.
And then they are all registered, of course only if they are available,
but disregarding $TERM and $DISPLAY.
So mozilla _is_ registered, and _is_ in _tryorder, and _will_ be run.
And, surprise, surprise, I run mostly on the virual console, and not in X.

If it is supposed to be that way it's very strange for me.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-28 14:19

Message:
Logged In: YES 
user_id=6380

I don't think this is a bug. The report doesn't explain what
undesirable behavior follows, and it looks like some
platforms need the registration. Note that the registry is
independent from the try order -- the registry may contain
browsers that are not in the try order, but they won't be
used unless you add them to the try order yourself.

Closing this as Invalid.

BTW, please encourage your users to interact with SF
directly rather than forwarding bugs from Debian here. It is
too painful.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=495695&group_id=5470