This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: raise error for common mistake with subprocess
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: astrand, ncw
Priority: normal Keywords: patch

Created on 2004-11-23 14:35 by ncw, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
check-for-forgotten-list.patch ncw, 2004-11-23 14:35 patch to check for forgotten args in list for subprocess
Messages (4)
msg47322 - (view) Author: Nick Craig-Wood (ncw) * Date: 2004-11-23 14:35
subprocess has a very easy to mistake error in it -
forgetting to pass the command as a list.  Eg

>>> import subprocess
>>> subprocess.call("ls")
BaseHTTPServer.py      dummy_threading.py 
pickletools.py   socket.py
Bastion.py             email               pipes.py   
     sre.py
[...]
dummy_thread.py        pickle.pyc          sndhdr.py  
     zipfile.py
0
>>> subprocess.call("ls", "-l")
BaseHTTPServer.py      dummy_threading.py 
pickletools.py   socket.py
Bastion.py             email               pipes.py   
     sre.py
[...]
dummy_thread.py        pickle.pyc          sndhdr.py  
     zipfile.py
0
>>> 

# Note no error, warning or anything, but no "ls -l" either

And 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?
>>> 
msg47323 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-11-30 21:55
Logged In: YES 
user_id=344921

I've applied the patch (slightly modified) on the CVS trunk:
subprocess.py 1.10
test_subprocess.py 1.16

I've not committed the patch to the 2.4 branch, however. 
msg47324 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-12-01 14:03
Logged In: YES 
user_id=344921

Should be applied to the 2.4 branch as well. 
msg47325 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-12-05 20:05
Logged In: YES 
user_id=344921

Now applied to 2.4-branch:

subprocess.py: 1.8.2.2
test_subprocess.py: 1.15.2.1
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41217
2004-11-23 14:35:03ncwcreate