[Python-bugs-list] [ python-Bugs-687747 ] _iscommand() in webbrowser module

SourceForge.net noreply@sourceforge.net
Sun, 02 Mar 2003 17:19:40 -0800


Bugs item #687747, was opened at 2003-02-16 23:17
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=687747&group_id=5470

Category: Python Library
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthew Cowles (mdcowles)
>Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: _iscommand() in webbrowser module

Initial Comment:
[From a post to python-help]

Under KDE under Mandrake Linux the BROWSER environment
variable is set to

kfmclient openProfile webbrowsing

The problem is that _iscommand() in the webbrowser
module doesn't realize that only the first thing there
is the name of the executable. It looks for an
executable with that whole thing as its name and
doesn't find one. Since the module doesn't use any
browser it has found if BROWSER is set, it raises an
error rather than opening the page.

The possible fixes that are obvious to me all have
potential disadvantages:

One solution would be to assume that the name of the
executable ran only up to the first space. But
executables can have spaces in their names, especially
on a Macintosh, I think.

Another possibility would be not to call _iscommand()
on anything in BROWSER. That would have the additional
advantage of not requiring that the executable
specified there be in a directory that's in the user's
PATH. The problem with doing things this way is that it
would be impossible to tell which of the browsers
specified in BROWSER should be used until the user
called open().

I'm prepared to work on a fix if given some guidance
about the best way to go.

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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2003-03-02 20:19

Message:
Logged In: YES 
user_id=6380

You know, I have no idea why all the lower() business is
there. Assigning to Fred Drake, maybe he knows more. (Fred,
please treat this as a hot potato -- if you don't
immediately know the answer, assign it back to me.)

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

Comment By: Matthew Cowles (mdcowles)
Date: 2003-03-02 15:43

Message:
Logged In: YES 
user_id=198518

A week after posting <slrnb5iu1s.t8.matt@sake.mondoinfo.com>
("webbrowser module under MacOS"), it hasn't gotten any
replies. That suggests that Mac users either don't much care
about the module or don't read comp.lang.python.

If it's desirable merely to stop at the first space, it
should be sufficient to replace:

if _iscommand(cmd.lower()):

with

if _iscommand(cmd.lower().split(" ")[0]):

There remain some things that are dubious about the handling
of the values in the BROWSER environment variable. In
particular, the lower() in that line, the assumption that
the executables specified in BROWSER are in the user's PATH,
and the lack of handling of %% and %s in those values.

Still, it may be reasonable to ignore those issues until
they pose a problem.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-02-23 08:53

Message:
Logged In: YES 
user_id=6380

Please ask around on c.l.py if the macintosh problem
actually exists; if it doesn't, stopping at the first space
sounds like the right idea.

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

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