Bugs item #1338995, was opened at 2005-10-26 16:08
Message generated for change (Comment added) made by gregcouch
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1338995&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Greg Couch (gregcouch)
Assigned to: Nobody/Anonymous (nobody)
Summary: CVS webbrowser.py (1.40) bugs

Initial Comment:
There are two calls to _safequote that are only made on
darwin, aka, Mac OS X.  That function is missing.

And the UnixBrowser is missing an & in the "simpler
command" and thus causes python to hang until the
browser is exited (if it wasn't running already).

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

>Comment By: Greg Couch (gregcouch)
Date: 2005-10-31 14:01

Message:
Logged In: YES 
user_id=131838

Breaking applications that use webbrowser does not help
application writers.  It would be much more useful to me, as
an application writer, if the webbrowser module gave an
error saying it couldn't contact a web browser, rather than
the new behavior of hanging my application.  You have yet to
address this common use case.

Running the webbrowser in the background is a contract that
the webbrowser module can't break and still be called the
webbrowser module.  I agree that the 2.4.2 version is a
practical hack that should be fixed, but the CVS webbrower
almost fixes it while breaking existing applications.  Since
adding an & is so bad (the web browser is already confirmed
to exist and to be executable), the CVS webbrower could be
changed to use the subprocess module instead of os.system,
and the original webbrowser contract could be preserved.  

The wrong display or wrong xhost/xauth permissions are not a
problem because the python GUI application that calls
webbrowser would have failed to start up in the first place
if those problems existed. Starting the web browser in the
background only needs to confirm that the web browser
actually started up.

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

Comment By: Oleg Broytmann (phd)
Date: 2005-10-31 05:11

Message:
Logged In: YES 
user_id=4799

Yes, I want.

Current practice of running a browser in the background by
default is deadly broken. The old code of webbrowser.py is
full of dirty hacks. Look at Netscape._remote(). It tries to
start a browser to send a remote command; if that fails it
tries to start the browser in the background, waits an
arbitrary number of seconds (why this? why not less? why not
more?) and without testing if the browser in the background
was started it retries sending the remote command. You can
never know if the browser was started and if the command was
sent becuase .open() does not return a result code.

At the global level the bug is that webbrowser.py doesn't
tri all browsers in the tryorder - it only concentrates on
the first it found in PATH. What if the brwoser cannot be
started (damaged disk image; wrong DISAPLY; wrong
xhost/xauth permissions)?

My patched webbrowser.py is much safer. It runs all browsers
in the tryorder until it finds one that can be started. One
doesn't need to wait a random number of seconds, too little
for slow systems, too many for fast. .open() returns a
success/fail status (on systems where it is possible to
obtain one).

The framework still alows you to shoot yourself in the foot,
but you must do it explicitly. Either run

os.system("shotgun-browser &")

yourself or register your own ShotgunBrowser. Thus the new
framework is safe by default but still flexible.

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

Comment By: Greg Couch (gregcouch)
Date: 2005-10-28 11:49

Message:
Logged In: YES 
user_id=131838

So you really want to change existing practice and break all
Python GUI programs that invoke webbrowser.open?

And the Elinks example proves my point.  What is the point
of it being a UnixBrowser, in the terminal window, if you
can't send remote commands to it (because the Python GUI
application is blocked until the browser exits)?  Tty-based
browsers are nice for completeness, but are really a last
resort for a Python application, and imply that no windowing
system is available (i.e, remotely logged in and not
forwarding X connections, so not running GUI applications
either).

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

Comment By: Oleg Broytmann (phd)
Date: 2005-10-28 04:56

Message:
Logged In: YES 
user_id=4799

No, I still think it is a bad idea to put a generic Unix
browser to background by default. If you want to do it - do
it explicitly. Start a browser in a background yourself, and
use remote actions from the module to open new windows/tabs.
Or register another browser, with different .open() and/or
._remote().

And, BTW, Elinks is a subclass of UnixBrowser, not
GenericBrowser.

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

Comment By: Greg Couch (gregcouch)
Date: 2005-10-27 10:35

Message:
Logged In: YES 
user_id=131838

And I don't want starting up firefox to hang my python GUI
either.  So, if you look at the code more closely,
lynx/links/elinks subclass from GenericBrowser not
UnixBrowser, so adding the & to UnixBrowser is the correct
thing to do.

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

Comment By: Oleg Broytmann (phd)
Date: 2005-10-27 08:36

Message:
Logged In: YES 
user_id=4799

Yes, _safequote() call seems like a bug. A leftover after
I've merged a half dozens of patches into this one. Should
be removed.

But there should certainly be no '&'. You certainly dont
want to start lynx/links/elinks in the background, do you?!

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1338995&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to