[Python-Dev] Re: Two patches for the new subprocess module

Russell E. Owen rowen at cesmail.net
Tue Nov 23 21:47:37 CET 2004


In article <20041123150846.GA22827 at craig-wood.com>,
 Nick Craig-Wood <nick at craig-wood.com> wrote:

> I have submitted two patches for the subprocess module against cvs
> HEAD.  The first notifies the user of a common mistake...
>
> subprocess has a very easy to mistake error in it - forgetting to pass
> the command as a list.... with the patch...
> 
> >>> subprocess.call("ls", "-l")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "subprocess.py", line 428, in call
>     return Popen(*args, **kwargs).wait()
>   File "subprocess.py", line 508, in __init__
>     raise TypeError("bufsize must be an integer - "
> TypeError: bufsize must be an integer - did you forget to pass your arguments 
> in a list?

I hope you didn't totally eliminate the ability for Popen and call to 
accept args as a string? It is a useful feature and one I've been using.

If you have broken this, please consider some alternative to your patch.

Perhaps changing the default for shell to True if args is a string, 
False if a list would suffice? I'm not sure this is really the right 
thing to do on all platforms, but it'd be an easy fix (use shell=None in 
the argument list and then convert it to True or False as needed).

One could imagine other fixes, such as offering one variant each of 
Popen and call that insists on args=string, leaving the main version to 
insist on args=list.

Regards,

-- Russell



More information about the Python-Dev mailing list