[ python-Bugs-875471 ] Make popen raise an exception if cmd doesn't exist

SourceForge.net noreply at sourceforge.net
Mon Apr 12 00:45:16 EDT 2004


Bugs item #875471, was opened at 2004-01-12 08:27
Message generated for change (Comment added) made by isandler
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=875471&group_id=5470

Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Nicolas Fleury (nidoizo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Make popen raise an exception if cmd doesn't exist

Initial Comment:
Right now, there's seems to be no difference between
executing a command that doesn't exist and a command
returning 1.  It would be more practical to raise an
exception when trying to execute a system command that
doesn't exist, since it's always an error, and
providing the user the capability to give different
error messages.


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

Comment By: Ilya Sandler (isandler)
Date: 2004-04-11 21:45

Message:
Logged In: YES 
user_id=971153

would 
import os
if os.access( path, os.X_OK) ==1:
    xxx

do what you want?

Or do you need to also search through the PATH, check for
"executable extensions" on Windows,etc (basically to emulate
an OS/shell-specific executable search algorithm)?

Then you may want to take a look at 
http://starship.python.net/~tmick/#which

(Would it be a good idea to have "which" module a part of
std lib? I do not know,  but  it's definitely not related to
popen() issue) 

Do you think this bug should be closed? If you agree, could
you close it?
Thanks

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

Comment By: Nicolas Fleury (nidoizo)
Date: 2004-04-11 20:16

Message:
Logged In: YES 
user_id=151545

I agree.  But should a portable way to look if a command
exists be available?

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

Comment By: Ilya Sandler (isandler)
Date: 2004-04-11 19:24

Message:
Logged In: YES 
user_id=971153

This is not a bug. And, in fact, I don't consider the
suggested behaviour even desirable

1) most programmers are used to the current behaviour
2) the change would be incompatible with current
applications (which simply check the return code of close())
3) if implemented it may make error checking more
complicated that it is now (b/c you would have to check for
2 things: exception on popen() and return code of close())
4) it may be impossible to implement correctly (on Unix at
least), due to race conditions (e.g executable can disappear
after you check but before you try to execute it)

Finally, if checking for this particular condition is
important for the application, then it is easy to check it
at a point of call


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

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



More information about the Python-bugs-list mailing list