Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subprocess: move shell arguments to a separate keyword param #57406

Closed
techtonik mannequin opened this issue Oct 17, 2011 · 6 comments
Closed

subprocess: move shell arguments to a separate keyword param #57406

techtonik mannequin opened this issue Oct 17, 2011 · 6 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@techtonik
Copy link
Mannequin

techtonik mannequin commented Oct 17, 2011

BPO 13197
Nosy @rhettinger, @vstinner
Superseder
  • 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 = None
    closed_at = <Date 2022-03-25.11:42:00.480>
    created_at = <Date 2011-10-17.11:41:11.103>
    labels = ['type-feature', 'library']
    title = 'subprocess: move shell arguments to a separate keyword param'
    updated_at = <Date 2022-03-25.11:42:00.479>
    user = 'https://bugs.python.org/techtonik'

    bugs.python.org fields:

    activity = <Date 2022-03-25.11:42:00.479>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-03-25.11:42:00.480>
    closer = 'iritkatriel'
    components = ['Library (Lib)']
    creation = <Date 2011-10-17.11:41:11.103>
    creator = 'techtonik'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 13197
    keywords = []
    message_count = 6.0
    messages = ['145669', '145670', '145675', '145676', '145877', '145887']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'vstinner', 'techtonik', 'Arfrever', 'cvrebert', 'rosslagerwall']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '7839'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue13197'
    versions = ['Python 3.3']

    @techtonik
    Copy link
    Mannequin Author

    techtonik mannequin commented Oct 17, 2011

    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.

    @techtonik techtonik mannequin added the stdlib Python modules in the Lib dir label Oct 17, 2011
    @vstinner
    Copy link
    Member

    Did you read the issue bpo-7839?

    @techtonik
    Copy link
    Mannequin Author

    techtonik mannequin commented 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
    Copy link
    Mannequin Author

    techtonik mannequin commented 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
    Copy link
    Contributor

    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
    Copy link
    Mannequin Author

    techtonik mannequin commented 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.

    @terryjreedy terryjreedy added the type-feature A feature request or enhancement label Oct 21, 2011
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants