You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
subprocess: move shell arguments to a separate keyword param #57406
bpo-7839: Popen should raise ValueError if pass a string when shell=False or a list when shell=True
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2022-03-25.11:42:00.480>created_at=<Date2011-10-17.11:41:11.103>labels= ['type-feature', 'library']
title='subprocess: move shell arguments to a separate keyword param'updated_at=<Date2022-03-25.11:42:00.479>user='https://bugs.python.org/techtonik'
subprocess.Popen(args, shell=shell) is implicitly inconsistent on Unix:
when shell=False, the args should be a list or you'll lose program options
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.
No. I won't be fixed in 2.7 anyway, and if it can not be fixed, it should be documented at least.
techtonik commented on Oct 17, 2011
techtonikmannequin
MannequinAuthor
More actions
Oh, sorry - my attention span is limited under time pressure. bpo-7839 is related, of course. There is a lot of comments, so I'll take a look at it later.
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).
techtonik commented on Oct 19, 2011
techtonikmannequin
MannequinAuthor
More actions
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.
Activity
techtonik commentedon Oct 17, 2011
subprocess.Popen(args, shell=shell) is implicitly inconsistent on Unix:
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.
vstinner commentedon Oct 17, 2011
Did you read the issue bpo-7839?
techtonik commentedon Oct 17, 2011
No. I won't be fixed in 2.7 anyway, and if it can not be fixed, it should be documented at least.
techtonik commentedon Oct 17, 2011
Oh, sorry - my attention span is limited under time pressure. bpo-7839 is related, of course. There is a lot of comments, so I'll take a look at it later.
rhettinger commentedon Oct 18, 2011
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).
techtonik commentedon Oct 19, 2011
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.