From cdab3bf7eb0810fcda21be065868f3da330779a1 Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Wed, 18 Jul 2001 20:03:32 +0000 Subject: If the user's environment has set the BROWSER environment variable (as Gnome seems to do), the user may not be aware of its contents. Attempt to add any to _browsers. closes bug #429136 --- Lib/webbrowser.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index ad195e0..055705d 100644 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -306,11 +306,14 @@ if os.environ.has_key("BROWSER"): # 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(":") -else: - # Optimization: filter out alternatives that aren't available, so we can - # avoid has_key() tests at runtime. (This may also allow some unused - # classes and class-instance storage to be garbage-collected.) - _tryorder = filter(lambda x: _browsers.has_key(x.lower()) - or x.find("%s") > -1, _tryorder) + +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) +# what to do if _tryorder is now empty? # end -- cgit v0.12