[New-bugs-announce] [issue30079] Explain why it is recommended to pass args as a string rather than as a sequence If shell is True

Philip Lee report at bugs.python.org
Sat Apr 15 23:10:04 EDT 2017


New submission from Philip Lee:

The doc here 
https://docs.python.org/3/library/subprocess.html#subprocess.Popen
says :
"If shell is True, it is recommended to pass args as a string rather than as a sequence."
but without explain why ? Please add the explanation !
while in
https://docs.python.org/3/library/subprocess.html#frequently-used-arguments
says:
"args is required for all calls and should be a string, or a sequence of program arguments. Providing a sequence of arguments is generally preferred, as it allows the module to take care of any required escaping and quoting of arguments (e.g. to permit spaces in file names). If passing a single string, either shell must be True (see below) or else the string must simply name the program to be executed without specifying any arguments."

In the case of shell =True ,  I found providing a sequence of arguments  rather than  a string argument can take the advantage of auto escaping and quoting of arguments (e.g. to permit spaces in file names) , so what is the advantage of pass args as a string rather than as a sequence as says in the doc when shell is True?

----------
assignee: docs at python
components: Documentation
messages: 291733
nosy: docs at python, iMath
priority: normal
severity: normal
status: open
title: Explain why it is recommended to pass args as a string rather than as a sequence If shell is True
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30079>
_______________________________________


More information about the New-bugs-announce mailing list