homepage

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: subprocess: move shell arguments to a separate keyword param
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Popen should raise ValueError if pass a string when shell=False or a list when shell=True
View: 7839
Assigned To: Nosy List: Arfrever, cvrebert, rhettinger, rosslagerwall, techtonik, vstinner
Priority: normal Keywords:

Created on 2011年10月17日 11:41 by techtonik, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (6)
msg145669 - (view) Author: anatoly techtonik (techtonik) Date: 2011年10月17日 11:41
subprocess.Popen(args, shell=shell) is implicitly inconsistent on Unix:
 1. when shell=False, the args should be a list or you'll lose program options
 2. when shell=True, the args should be a string or your program options will be passed to shell itself
I propose to make consistent behaviour - require args to be a list, and pass shell options in a separate shell_args keyword argument. If it not for python4, then perhaps it can be implemented in PopenShell() and PopenSystem() functions.
This will also require unification of behaviour across platforms.
msg145670 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011年10月17日 11:43
Did you read the issue #7839?
msg145675 - (view) Author: anatoly techtonik (techtonik) Date: 2011年10月17日 12:18
No. I won't be fixed in 2.7 anyway, and if it can not be fixed, it should be documented at least.
msg145676 - (view) Author: anatoly techtonik (techtonik) Date: 2011年10月17日 12:21
Oh, sorry - my attention span is limited under time pressure. #7839 is related, of course. There is a lot of comments, so I'll take a look at it later.
msg145877 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011年10月18日 23:52
I don't think you can tighten the API at this point. We could however make Popen complain when options are going to be thrown away. Or it could be made more liberal about what is accepts (running shlex on string input or join on list input as needed).
msg145887 - (view) Author: anatoly techtonik (techtonik) Date: 2011年10月19日 06:13
List not only needs to be joined, it should be quoted as well. But the biggest problem will be the change of behavior between Python versions which may confuse users even more.
Perhaps it's a good time to start embedding 'best practice' recipes in manual.
History
Date User Action Args
2022年04月11日 14:57:22adminsetgithub: 57406
2022年03月25日 11:42:00iritkatrielsetstatus: open -> closed
superseder: Popen should raise ValueError if pass a string when shell=False or a list when shell=True
resolution: duplicate
stage: resolved
2014年05月16日 05:55:22cvrebertsetnosy: + cvrebert
2011年10月21日 21:50:36terry.reedysettype: enhancement
versions: + Python 3.3
2011年10月19日 06:13:35techtoniksetmessages: + msg145887
2011年10月18日 23:52:25rhettingersetnosy: + rhettinger
messages: + msg145877
2011年10月17日 14:01:26Arfreversetnosy: + Arfrever
2011年10月17日 12:21:58techtoniksetmessages: + msg145676
2011年10月17日 12:18:02techtoniksetmessages: + msg145675
2011年10月17日 12:12:36rosslagerwallsetnosy: + rosslagerwall
2011年10月17日 11:43:09vstinnersetnosy: + vstinner
messages: + msg145670
2011年10月17日 11:41:11techtonikcreate

AltStyle によって変換されたページ (->オリジナル) /